mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-02 00:02:19 -07:00
refactor UI backend calls to python endpoints
This commit is contained in:
@@ -74,6 +74,28 @@ def row_to_json(names, row):
|
||||
return rowEntry
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------
|
||||
def safe_int(setting_name):
|
||||
"""
|
||||
Helper to ensure integer values are valid (not empty strings or None).
|
||||
|
||||
Parameters:
|
||||
setting_name (str): The name of the setting to retrieve.
|
||||
|
||||
Returns:
|
||||
int: The setting value as an integer if valid, otherwise 0.
|
||||
"""
|
||||
# Import here to avoid circular dependency
|
||||
from helper import get_setting_value
|
||||
try:
|
||||
val = get_setting_value(setting_name)
|
||||
if val in ['', None, 'None', 'null']:
|
||||
return 0
|
||||
return int(val)
|
||||
except (ValueError, TypeError, Exception):
|
||||
return 0
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------
|
||||
def sanitize_SQL_input(val):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user