From 78ab0fbd2db536aa81989141bd549fa4420266a7 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Fri, 31 Oct 2025 20:24:13 +1100 Subject: [PATCH] PLG: SNMPDSC typo --- front/plugins/_publisher_email/config.json | 2 +- front/plugins/snmp_discovery/config.json | 2 +- server/helper.py | 24 +++++++++++++-- server/initialise.py | 34 +++++++++------------- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/front/plugins/_publisher_email/config.json b/front/plugins/_publisher_email/config.json index 387c8d7a..ed147e61 100755 --- a/front/plugins/_publisher_email/config.json +++ b/front/plugins/_publisher_email/config.json @@ -534,7 +534,7 @@ { "elementType": "input", "elementOptions": [{ "type": "password" }], - "transformers": [] + "transformers": ["base64"] } ] }, diff --git a/front/plugins/snmp_discovery/config.json b/front/plugins/snmp_discovery/config.json index 9b6dce62..19f63233 100755 --- a/front/plugins/snmp_discovery/config.json +++ b/front/plugins/snmp_discovery/config.json @@ -483,7 +483,7 @@ "description": [ { "language_code": "en_us", - "string": "A list of snmpwalk commands to execute against IP addresses of roputers/switches with SNMP turned on.

Example with the router on the IP 192.168.1.1 (the -OXsq is a required parameter):
snmpwalk -v 2c -c public -OXsq 192.168.1.1 .1.3.6.1.2.1.3.1.1.2

Only IPv4 supported. Authentication is not supported. More info on the plugin here." + "string": "A list of snmpwalk commands to execute against IP addresses of routers/switches with SNMP turned on.

Example with the router on the IP 192.168.1.1 (the -OXsq is a required parameter):
snmpwalk -v 2c -c public -OXsq 192.168.1.1 .1.3.6.1.2.1.3.1.1.2

Only IPv4 supported. Authentication is not supported. More info on the plugin here." }, { "language_code": "es_es", diff --git a/server/helper.py b/server/helper.py index bb74ef5a..e48958b8 100755 --- a/server/helper.py +++ b/server/helper.py @@ -768,11 +768,19 @@ def collect_lang_strings(json, pref, stringSqlParams): return stringSqlParams #------------------------------------------------------------------------------- -def checkNewVersion(): - mylog('debug', [f"[Version check] Checking if new version available"]) +# Get the value from the buildtimestamp.txt and initialize it if missing +def getBuildTimeStamp(): + """ + Retrieves the build timestamp from 'front/buildtimestamp.txt' within the + application directory. - newVersion = False + If the file does not exist, it is created and initialized with the value '0'. + Returns: + int: The integer value of the build timestamp read from the file. + Returns 0 if the file is empty or just initialized. + """ + buildTimestamp = 0 build_timestamp_path = os.path.join(applicationPath, 'front/buildtimestamp.txt') # Ensure file exists, initialize if missing @@ -784,6 +792,16 @@ def checkNewVersion(): with open(build_timestamp_path, 'r') as f: buildTimestamp = int(f.read().strip() or 0) + return buildTimestamp + + +#------------------------------------------------------------------------------- +def checkNewVersion(): + mylog('debug', [f"[Version check] Checking if new version available"]) + + newVersion = False + buildTimestamp = getBuildTimeStamp() + try: response = requests.get( "https://api.github.com/repos/jokob-sk/NetAlertX/releases", diff --git a/server/initialise.py b/server/initialise.py index ac8062a1..0a8fa82d 100755 --- a/server/initialise.py +++ b/server/initialise.py @@ -12,7 +12,7 @@ import re # Register NetAlertX libraries import conf from const import fullConfPath, applicationPath, fullConfFolder, default_tz -from helper import fixPermissions, collect_lang_strings, updateSubnets, isJsonObject, setting_value_to_python_type, timeNowTZ, get_setting_value, generate_random_string +from helper import getBuildTimeStamp, fixPermissions, collect_lang_strings, updateSubnets, isJsonObject, setting_value_to_python_type, timeNowTZ, get_setting_value, generate_random_string from app_state import updateState from logger import mylog from api import update_api @@ -378,29 +378,21 @@ def importConfigs (pm, db, all_plugins): # HANDLE APP was upgraded message - clear cache # Check if app was upgraded - build_timestamp_path = os.path.join(applicationPath, 'front/buildtimestamp.txt') - - # Ensure the build timestamp file exists and has an initial value - if not os.path.exists(build_timestamp_path): - with open(build_timestamp_path, 'w') as f: - f.write("0") - - with open(build_timestamp_path, 'r') as f: - buildTimestamp = int(f.read().strip()) - cur_version = conf.VERSION + buildTimestamp = getBuildTimeStamp() + cur_version = conf.VERSION + + mylog('debug', [f"[Config] buildTimestamp: '{buildTimestamp}'"]) + mylog('debug', [f"[Config] conf.VERSION : '{cur_version}'"]) + + if str(cur_version) != str(buildTimestamp): - mylog('debug', [f"[Config] buildTimestamp: '{buildTimestamp}'"]) - mylog('debug', [f"[Config] conf.VERSION : '{cur_version}'"]) + mylog('none', ['[Config] App upgraded 🚀']) + + # ccd(key, default, config_dir, name, inputtype, options, group, events=None, desc="", setJsonMetadata=None, overrideTemplate=None, forceDefault=False) + ccd('VERSION', buildTimestamp , c_d, '_KEEP_', '_KEEP_', '_KEEP_', '_KEEP_', None, "_KEEP_", None, None, True) - if str(cur_version) != str(buildTimestamp): - - mylog('none', ['[Config] App upgraded 🚀']) - - # ccd(key, default, config_dir, name, inputtype, options, group, events=None, desc="", setJsonMetadata=None, overrideTemplate=None, forceDefault=False) - ccd('VERSION', buildTimestamp , c_d, '_KEEP_', '_KEEP_', '_KEEP_', '_KEEP_', None, "_KEEP_", None, None, True) - - write_notification(f'[Upgrade] : App upgraded 🚀 Please clear the cache:
  1. Click OK below
  2. Clear the browser cache (shift + browser refresh button)
  3. Clear app cache with the (reload) button in the header
  4. Go to Settings and click Save
Check out new features and what has changed in the 📓 release notes.', 'interrupt', timeNowTZ()) + write_notification(f'[Upgrade] : App upgraded 🚀 Please clear the cache:
  1. Click OK below
  2. Clear the browser cache (shift + browser refresh button)
  3. Clear app cache with the (reload) button in the header
  4. Go to Settings and click Save
Check out new features and what has changed in the 📓 release notes.', 'interrupt', timeNowTZ())