MCPcopy Create free account
hub / github.com/WavesMan/Disable-automatic-Windows-update / _invoke

Function _invoke

python/core/main.py:35–71  ·  view source on GitHub ↗
(action: str, func)

Source from the content-addressed store, hash-verified

33
34
35def _invoke(action: str, func):
36 # NOTE: 编排层统一记录入口与结果,便于区分 UI 事件日志与服务层执行日志
37 start = time.perf_counter()
38 log_event(logging.INFO, "core_action_started", f"核心调用开始: {action}", action=action, status="started")
39 try:
40 result = func()
41 duration_ms = int((time.perf_counter() - start) * 1000)
42 if getattr(result, "ok", False):
43 log_event(logging.INFO, "core_action_finished", f"核心调用成功: {action}", action=action, status="ok", duration_ms=duration_ms)
44 else:
45 err_msg = (getattr(result, "error", None) or {}).get("message", "核心调用失败")
46 log_event(
47 logging.ERROR,
48 "core_action_finished",
49 f"核心调用失败: {action}",
50 action=action,
51 status="failed",
52 duration_ms=duration_ms,
53 error_type=(getattr(result, "error", None) or {}).get("code", "CORE_ACTION_FAILED"),
54 error_message=err_msg,
55 )
56 return result
57 except Exception as e:
58 duration_ms = int((time.perf_counter() - start) * 1000)
59 log_event(
60 logging.ERROR,
61 "core_action_exception",
62 f"核心调用异常: {action} - {e}",
63 action=action,
64 status="failed",
65 duration_ms=duration_ms,
66 error_type=type(e).__name__,
67 error_message=str(e),
68 traceback=traceback.format_exc(),
69 exc_info=True,
70 )
71 raise
72
73
74def pause_updates(max_days: int = 18300):

Callers 12

pause_updatesFunction · 0.85
resume_updatesFunction · 0.85
disable_defenderFunction · 0.85
enable_defenderFunction · 0.85
disable_onedriveFunction · 0.85
enable_onedriveFunction · 0.85
get_versionFunction · 0.85
export_logsFunction · 0.85
check_updateFunction · 0.85
disable_firewallFunction · 0.85
enable_firewallFunction · 0.85
pause_updates_with_timesFunction · 0.85

Calls 1

log_eventFunction · 0.85

Tested by

no test coverage detected