Compare commits

...

2 Commits

Author SHA1 Message Date
jared 31747c4bd3 Replace deprecated datetime.utcnow() with datetime.now(timezone.utc)
Lint / Python (flake8) (push) Successful in 1m9s
Lint / JS (eslint) (push) Successful in 11s
Security / Python Security (bandit) (push) Successful in 44s
Test / Python Tests (pytest) (push) Successful in 58s
Lint / Notify on failure (push) Has been skipped
Lint / Deploy (push) Successful in 3s
datetime.utcnow() is deprecated in Python 3.12 and removed in 3.13.
Replace all four call sites with timezone-aware equivalents so the
codebase is ready for Python 3.12+.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 15:34:41 -04:00
jared faa0707f79 Add ESLint config enforcing no-undef and eqeqeq
Lint / Python (flake8) (push) Successful in 53s
Lint / JS (eslint) (push) Successful in 12s
Security / Python Security (bandit) (push) Successful in 1m44s
Test / Python Tests (pytest) (push) Successful in 59s
Lint / Notify on failure (push) Has been skipped
Lint / Deploy (push) Successful in 3s
Without a config file, ESLint was running with no-undef disabled, meaning
undefined variable references in static/app.js were silently ignored.
Add .eslintrc.json with no-undef: error and eqeqeq: error so CI actually
catches JS bugs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 15:33:26 -04:00
3 changed files with 27 additions and 6 deletions
+21
View File
@@ -0,0 +1,21 @@
{
"env": {
"browser": true,
"es2021": true
},
"globals": {
"lt": "readonly",
"GANDALF_CONFIG": "readonly",
"CSS": "readonly"
},
"rules": {
"no-undef": "error",
"no-unused-vars": ["warn", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }],
"no-console": "off",
"eqeqeq": ["error", "always", { "null": "ignore" }]
},
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "script"
}
}
+2 -2
View File
@@ -3,7 +3,7 @@ import json
import logging import logging
import threading import threading
from contextlib import contextmanager from contextlib import contextmanager
from datetime import datetime, timedelta from datetime import datetime, timedelta, timezone
from typing import Optional from typing import Optional
import pymysql import pymysql
@@ -281,7 +281,7 @@ def create_suppression(
) -> int: ) -> int:
expires_at = None expires_at = None
if expires_minutes: if expires_minutes:
expires_at = datetime.utcnow() + timedelta(minutes=int(expires_minutes)) expires_at = datetime.now(timezone.utc) + timedelta(minutes=int(expires_minutes))
with get_conn() as conn: with get_conn() as conn:
with conn.cursor() as cur: with conn.cursor() as cur:
cur.execute( cur.execute(
+4 -4
View File
@@ -12,7 +12,7 @@ import logging
import re import re
import shlex import shlex
import time import time
from datetime import datetime from datetime import datetime, timezone
from typing import Dict, List, Optional from typing import Dict, List, Optional
import requests import requests
@@ -618,7 +618,7 @@ class LinkStatsCollector:
return { return {
'hosts': result_hosts, 'hosts': result_hosts,
'unifi_switches': unifi_switches, 'unifi_switches': unifi_switches,
'updated': datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S UTC'), 'updated': datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M:%S UTC'),
} }
def _compute_unifi_rates(self, raw: Dict[str, dict], now: float) -> Dict[str, dict]: def _compute_unifi_rates(self, raw: Dict[str, dict], now: float) -> Dict[str, dict]:
@@ -653,7 +653,7 @@ class LinkStatsCollector:
# Helpers # Helpers
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
def _now_utc() -> str: def _now_utc() -> str:
return datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S UTC') return datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M:%S UTC')
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
@@ -921,7 +921,7 @@ class NetworkMonitor:
return { return {
'hosts': hosts, 'hosts': hosts,
'unifi': display_unifi, 'unifi': display_unifi,
'updated': datetime.utcnow().isoformat() + 'Z', 'updated': datetime.now(timezone.utc).isoformat().replace('+00:00', 'Z'),
} }
# ------------------------------------------------------------------ # ------------------------------------------------------------------