47 lines
2.7 KiB
Python
47 lines
2.7 KiB
Python
from pathlib import Path
|
|
import shutil
|
|
|
|
for root in (Path('C:/wechat_rpa'),Path('C:/kefu/wechat_rpa')):
|
|
path=root/'gui_runtime.py'
|
|
text=path.read_text(encoding='utf-8')
|
|
old=''' if requested - confirmed:
|
|
self._handoff_bot_tasks(bot, requested - confirmed, confirm_uncertain=False)
|
|
if confirmed:
|
|
self._handoff_bot_tasks(bot, confirmed, confirm_uncertain=True)
|
|
'''
|
|
new=''' if requested - confirmed:
|
|
result = self._handoff_bot_tasks(bot, requested - confirmed, confirm_uncertain=False)
|
|
self._report_queued_handoff_result(result)
|
|
if confirmed:
|
|
result = self._handoff_bot_tasks(bot, confirmed, confirm_uncertain=True)
|
|
self._report_queued_handoff_result(result)
|
|
|
|
def _report_queued_handoff_result(self, result):
|
|
"""Report startup command results without turning a retry into consent."""
|
|
result = result if isinstance(result, dict) else {}
|
|
if result.get("error"):
|
|
self.target_queue.put(("log", "[转人工] 启动后处理交接失败,请返回任务队列核对:" + str(result["error"])))
|
|
return
|
|
accepted = set(result.get("handed_off") or result.get("deleted") or [])
|
|
pending_confirmation = set(result.get("requires_confirmation") or [])
|
|
protected = set(result.get("protected") or []) - pending_confirmation
|
|
scheduled = set(result.get("scheduled") or [])
|
|
missing = set(result.get("missing") or [])
|
|
if accepted:
|
|
self.target_queue.put(("log", f"[转人工] 启动后已将 {len(accepted)} 条任务交给人工;保留发送记录,不自动重发。"))
|
|
if pending_confirmation:
|
|
self.target_queue.put(("log", f"[转人工] {len(pending_confirmation)} 条任务的发送结果需要核对,此次未执行移交。请返回任务队列,在企业微信核对后重新点击转人工并确认。"))
|
|
if protected:
|
|
self.target_queue.put(("log", f"[转人工] {len(protected)} 条任务仍受发送或账号保护,此次未执行移交。请返回任务队列查看原因。"))
|
|
if scheduled:
|
|
self.target_queue.put(("log", f"[转人工] {len(scheduled)} 条任务仍在等待处理,尚未完成交接。"))
|
|
if missing:
|
|
self.target_queue.put(("log", f"[转人工] {len(missing)} 条任务已不在待处理队列,此次未执行交接。"))
|
|
'''
|
|
assert text.count(old)==1,str(path)
|
|
text=text.replace(old,new)
|
|
compile(text,str(path),'exec')
|
|
path.write_text(text,encoding='utf-8')
|
|
shutil.copy2(Path(__file__).with_name('test_queued_handoff_report.py'),root/'test_queued_handoff_report.py')
|
|
print('Both runtimes now report actual startup handoff outcomes without auto-confirmation.')
|