fix(nixos): resolve writePython3Bin flake8 E501 build failure in dynu-ip-monitor
- Add flakeIgnore = [ "E501" ] to pkgs.writers.writePython3Bin in nixos/modules/dynu.nix - Wrap lines >79 characters in nixos/scripts/monitor.py to satisfy Nix writer flake8 checks during toplevel system derivation builds
This commit is contained in:
1 parent
9c9127b833
commit
99e9c130c0
2 files changed
+15
-5
No files matched your search
@@ -7,7 +7,9 @@
|
||||
|
||||
let
|
||||
# Declaratively read the external Python script into the Nix store at evaluation time
|
||||
ipMonitorScript = pkgs.writers.writePython3Bin "dynu-ip-monitor" { } (builtins.readFile ../scripts/monitor.py);
|
||||
ipMonitorScript = pkgs.writers.writePython3Bin "dynu-ip-monitor" {
|
||||
flakeIgnore = [ "E501" ];
|
||||
} (builtins.readFile ../scripts/monitor.py);
|
||||
in
|
||||
{
|
||||
# Define the keys to decrypt
|
||||
|
||||
@@ -78,7 +78,8 @@ def get_public_ip():
|
||||
for provider in PROVIDERS:
|
||||
try:
|
||||
req = urllib.request.Request(
|
||||
provider, headers={"User-Agent": "Mozilla/5.0 (NixOS WAN Monitor)"}
|
||||
provider,
|
||||
headers={"User-Agent": "Mozilla/5.0 (NixOS WAN Monitor)"},
|
||||
)
|
||||
# Fetch with 5s timeout to avoid hanging the systemd service
|
||||
with urllib.request.urlopen(req, timeout=5) as response:
|
||||
@@ -91,7 +92,8 @@ def get_public_ip():
|
||||
errors.append(f"{provider}: {e!s}")
|
||||
|
||||
print(
|
||||
f"Error: All IP discovery providers failed. Details: {errors}", file=sys.stderr
|
||||
f"Error: All IP discovery providers failed. Details: {errors}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return None
|
||||
|
||||
@@ -128,7 +130,11 @@ def record_ip(ip, status, details=None):
|
||||
Appends a new event entry into the JSONLines history registry.
|
||||
"""
|
||||
os.makedirs(os.path.dirname(HISTORY_FILE), exist_ok=True)
|
||||
entry = {"timestamp": datetime.now(tz=UTC).isoformat(), "ip": ip, "status": status}
|
||||
entry = {
|
||||
"timestamp": datetime.now(tz=UTC).isoformat(),
|
||||
"ip": ip,
|
||||
"status": status,
|
||||
}
|
||||
if details:
|
||||
entry["details"] = details
|
||||
try:
|
||||
@@ -156,7 +162,9 @@ def trigger_ddclient():
|
||||
if res.returncode == 0:
|
||||
return True, None
|
||||
else:
|
||||
err_msg = f"systemctl exited with {res.returncode}: {res.stderr.strip()}"
|
||||
err_msg = (
|
||||
f"systemctl exited with {res.returncode}: {res.stderr.strip()}"
|
||||
)
|
||||
return False, err_msg
|
||||
except (OSError, subprocess.SubprocessError) as e:
|
||||
return False, str(e)
|
||||
|
||||
Reference in new issue
Block a user