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

Method enable

python/core/services.py:425–449  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

423 return Result(False, error={"code": "FIREWALL_DISABLE_FAILED", "message": "防火墙停用失败", "details": errors})
424
425 def enable(self) -> Result:
426 start = time.perf_counter()
427 log_event(logging.INFO, "firewall_enable_started", "开始恢复防火墙", action="enable_firewall", status="started")
428 cmds = [
429 "netsh advfirewall set allprofiles state on",
430 "netsh advfirewall set domainprofile state on",
431 "netsh advfirewall set privateprofile state on",
432 "netsh advfirewall set publicprofile state on",
433 ]
434 ok, errors = self._batch(cmds)
435 duration_ms = int((time.perf_counter() - start) * 1000)
436 if ok:
437 log_event(logging.INFO, "firewall_enable_finished", "恢复防火墙成功", action="enable_firewall", status="ok", duration_ms=duration_ms)
438 return Result(True, data={"status": "firewall_enabled"})
439 log_event(
440 logging.ERROR,
441 "firewall_enable_finished",
442 "恢复防火墙失败",
443 action="enable_firewall",
444 status="failed",
445 duration_ms=duration_ms,
446 error_type="FIREWALL_ENABLE_FAILED",
447 error_message="; ".join(errors),
448 )
449 return Result(False, error={"code": "FIREWALL_ENABLE_FAILED", "message": "防火墙恢复失败", "details": errors})

Callers

nothing calls this directly

Calls 3

_batchMethod · 0.95
log_eventFunction · 0.85
ResultClass · 0.85

Tested by

no test coverage detected