diff --git a/docker-compose.yml b/docker-compose.yml index 4031c4d9..b30748e2 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -46,6 +46,7 @@ services: - ${DEV_LOCATION}/front/presence.php:/home/pi/pialert/front/presence.php - ${DEV_LOCATION}/front/settings.php:/home/pi/pialert/front/settings.php - ${DEV_LOCATION}/front/systeminfo.php:/home/pi/pialert/front/systeminfo.php + - ${DEV_LOCATION}/front/report.php:/home/pi/pialert/front/report.php - ${DEV_LOCATION}/front/flows.php:/home/pi/pialert/front/flows.php - ${DEV_LOCATION}/front/plugins:/home/pi/pialert/front/plugins # DELETE END anyone trying to use this file: comment out / delete ABOVE lines, they are only for development purposes diff --git a/pialert/__main__.py b/pialert/__main__.py index 0413d0a1..536aaec2 100755 --- a/pialert/__main__.py +++ b/pialert/__main__.py @@ -26,7 +26,7 @@ from const import * from logger import mylog from helper import filePermissions, isNewVersion, timeNowTZ, updateState from api import update_api -# from networkscan import process_scan, scan_network +from networkscan import process_scan from initialise import importConfigs from mac_vendor import update_devices_MAC_vendors from database import DB, get_all_devices @@ -205,10 +205,12 @@ def main (): if conf.ENABLE_PLUGINS: run_plugin_scripts(db,'always_after_scan') - # -------------------------------------------------- + # process all the scanned data into new devices - # mylog('debug', "[MAIN] start processig scan results") - # process_scan (db) + if conf.currentScanNeedsProcessing == True: + mylog('debug', "[MAIN] start processig scan results") + process_scan(db) + conf.currentScanNeedsProcessing = False # Reporting if conf.cycle in conf.check_report: @@ -261,6 +263,12 @@ def main (): time.sleep(5) # wait for N seconds + + + + + + #=============================================================================== # BEGIN #=============================================================================== diff --git a/pialert/conf.py b/pialert/conf.py index 4a5f3288..0b7f41a9 100755 --- a/pialert/conf.py +++ b/pialert/conf.py @@ -1,5 +1,11 @@ """ config related functions for Pi.Alert """ +# TODO: Create and manage this as part of an app_state class object +#=============================================================================== +# class app_state: +# def __init__(self, currentScanNeedsProcessing = False): +# self.currentScanNeedsProcessing = currentScanNeedsProcessing + # These are global variables, not config items and should not exist ! mySettings = [] @@ -15,6 +21,8 @@ tz = '' # set to a small value to force import at first run lastImportedConfFile = 1.1 +currentScanNeedsProcessing = False + plugins_once_run = False newVersionAvailable = False time_started = '' diff --git a/pialert/plugin.py b/pialert/plugin.py index 22ed5995..49ca8ec7 100755 --- a/pialert/plugin.py +++ b/pialert/plugin.py @@ -12,7 +12,6 @@ from const import pluginsPath, logPath from logger import mylog from helper import timeNowTZ, updateState, get_file_content, write_file, get_setting, get_setting_value from api import update_api -from networkscan import process_scan #------------------------------------------------------------------------------- def run_plugin_scripts(db, runType): @@ -24,7 +23,8 @@ def run_plugin_scripts(db, runType): for plugin in conf.plugins: - shouldRun = False + shouldRun = False + prefix = plugin["unique_prefix"] set = get_plugin_setting(plugin, "RUN") if set != None and set['value'] == runType: @@ -32,7 +32,7 @@ def run_plugin_scripts(db, runType): shouldRun = True elif runType == "schedule": # run if overdue scheduled time - prefix = plugin["unique_prefix"] + # check schedules if any contains a unique plugin prefix matching the current plugin for schd in conf.mySchedules: @@ -44,6 +44,8 @@ def run_plugin_scripts(db, runType): schd.last_run = timeNowTZ() if shouldRun: + # Header + updateState(db,f"Plugins: {prefix}") print_plugin_info(plugin, ['display_name']) mylog('debug', ['[Plugins] CMD: ', get_plugin_setting(plugin, "CMD")["value"]]) @@ -418,7 +420,8 @@ def combine_plugin_objects(old, new): def process_plugin_events(db, plugin): sql = db.sql - ##global pluginObjects, pluginEvents + # capturing if we need to process scan results for devices + conf.currentScanNeedsProcessing = False pluginPref = plugin["unique_prefix"] @@ -590,18 +593,12 @@ def process_plugin_events(db, plugin): db.commitDB() # perform scan if mapped to CurrentScan table - if dbTable == 'CurrentScan': - process_scan(db) - + if dbTable == 'CurrentScan': + conf.currentScanNeedsProcessing = True db.commitDB() - - - - - #------------------------------------------------------------------------------- class plugin_object_class: def __init__(self, plugin, objDbRow):