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

Method _batch

python/core/services.py:374–397  ·  view source on GitHub ↗
(self, cmds: List[str])

Source from the content-addressed store, hash-verified

372 # NOTE: 使用 netsh 控制所有防火墙配置文件开关,提高跨版本兼容性
373
374 def _batch(self, cmds: List[str]) -> Tuple[bool, List[str]]:
375 errors: List[str] = []
376 for cmd in cmds:
377 step_start = time.perf_counter()
378 log_event(logging.INFO, "firewall_command_started", "执行命令", action="firewall_command", status="started", cmd=cmd)
379 ok, out, err = run_cmd(cmd)
380 duration_ms = int((time.perf_counter() - step_start) * 1000)
381 if ok:
382 log_event(logging.INFO, "firewall_command_finished", "执行成功", action="firewall_command", status="ok", cmd=cmd, duration_ms=duration_ms)
383 else:
384 msg = err or out or "执行失败"
385 log_event(
386 logging.ERROR,
387 "firewall_command_finished",
388 f"执行失败: {msg}",
389 action="firewall_command",
390 status="failed",
391 cmd=cmd,
392 duration_ms=duration_ms,
393 error_type="CommandFailed",
394 error_message=msg,
395 )
396 errors.append(msg)
397 return (len(errors) == 0), errors
398
399 def disable(self) -> Result:
400 start = time.perf_counter()

Callers 2

disableMethod · 0.95
enableMethod · 0.95

Calls 2

log_eventFunction · 0.85
run_cmdFunction · 0.85

Tested by

no test coverage detected