mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
@@ -111,7 +111,6 @@ def update_api(
|
||||
# -------------------------------------------------------------------------------
|
||||
class api_endpoint_class:
|
||||
def __init__(self, db, forceUpdate, query, path, is_ad_hoc_user_event=False):
|
||||
global apiEndpoints
|
||||
|
||||
current_time = timeNowTZ()
|
||||
|
||||
@@ -222,7 +221,7 @@ periodic_write_thread = None
|
||||
|
||||
def periodic_write(interval=1):
|
||||
"""Periodically checks all endpoints for pending writes."""
|
||||
global apiEndpoints
|
||||
|
||||
while not stop_event.is_set():
|
||||
with api_lock:
|
||||
for endpoint in apiEndpoints:
|
||||
|
||||
@@ -96,7 +96,7 @@ def delete_unknown_devices():
|
||||
|
||||
def export_devices(export_format):
|
||||
"""
|
||||
Export devices from the Devices table in teh desired format.
|
||||
Export devices from the Devices table in the desired format.
|
||||
- If `macs` is None → delete ALL devices.
|
||||
- If `macs` is a list → delete only matching MACs (supports wildcard '*').
|
||||
"""
|
||||
|
||||
@@ -364,7 +364,6 @@ class Query(ObjectType):
|
||||
Collect language strings, optionally filtered by language code and/or string key.
|
||||
Caches in memory for performance. Can fallback to 'en_us' if a string is missing.
|
||||
"""
|
||||
global _langstrings_cache, _langstrings_cache_mtime
|
||||
|
||||
langStrings = []
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ def ensure_column(sql, table: str, column_name: str, column_type: str) -> bool:
|
||||
if column_name in actual_columns:
|
||||
return True # Already exists
|
||||
|
||||
# Define the expected columns (hardcoded base schema) [v25.5.24] - available in teh default app.db
|
||||
# Define the expected columns (hardcoded base schema) [v25.5.24] - available in the default app.db
|
||||
expected_columns = [
|
||||
"devMac",
|
||||
"devName",
|
||||
|
||||
@@ -248,8 +248,6 @@ def get_setting_value(key):
|
||||
Any: The Python-typed setting value, or an empty string if not found.
|
||||
"""
|
||||
|
||||
global SETTINGS_SECONDARYCACHE
|
||||
|
||||
# Returns empty string if not found
|
||||
value = ""
|
||||
|
||||
|
||||
@@ -94,7 +94,10 @@ class plugin_manager:
|
||||
|
||||
# 🔹 CMD also retrieved from cache
|
||||
cmd_setting = self._cache["settings"].get(prefix, {}).get("CMD")
|
||||
mylog("debug", f"[Plugins] CMD: {cmd_setting["value"] if cmd_setting else None}")
|
||||
|
||||
print_str = cmd_setting["value"] if cmd_setting else None
|
||||
|
||||
mylog("debug", f"[Plugins] CMD: {print_str}")
|
||||
|
||||
execute_plugin(self.db, self.all_plugins, plugin)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from dateutil import parser
|
||||
import datetime
|
||||
import re
|
||||
import pytz
|
||||
from typing import Union
|
||||
from typing import Union, Optional
|
||||
from zoneinfo import ZoneInfo
|
||||
import email.utils
|
||||
import conf
|
||||
@@ -112,9 +112,9 @@ def normalizeTimeStamp(inputTimeStamp):
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------
|
||||
def format_date_iso(date1: str) -> str:
|
||||
def format_date_iso(date1: str) -> Optional[str]:
|
||||
"""Return ISO 8601 string for a date or None if empty"""
|
||||
if date1 is None:
|
||||
if not date1:
|
||||
return None
|
||||
dt = datetime.datetime.fromisoformat(date1) if isinstance(date1, str) else date1
|
||||
return dt.isoformat()
|
||||
|
||||
Reference in New Issue
Block a user