added default DB

fixed re-import of config file
This commit is contained in:
Data-Monkey
2023-06-03 21:42:04 +10:00
parent 007611c429
commit 6bb891f830
6 changed files with 181 additions and 147 deletions

View File

@@ -13,10 +13,9 @@
#===============================================================================
# IMPORTS
#===============================================================================
from __future__ import print_function
#from __future__ import print_function
import sys
from collections import namedtuple
import time
import datetime
import multiprocessing
@@ -25,7 +24,7 @@ import multiprocessing
import conf
from const import *
from logger import mylog
from helper import filePermissions, isNewVersion, timeNow, timeNowTZ, updateState
from helper import filePermissions, isNewVersion, timeNow, updateState
from api import update_api
from networkscan import process_scan, scan_network
from initialise import importConfigs
@@ -75,6 +74,7 @@ main structure of Pi Alert
"""
def main ():
mylog('debug', ['[MAIN] Setting up ...'])
conf.time_started = datetime.datetime.now()
conf.cycle = ""
@@ -109,7 +109,7 @@ def main ():
# Open DB once and keep open
# Opening / closing DB frequently actually casues more issues
db = DB() # instance of class DB
db.openDB()
db.open()
sql = db.sql # To-Do replace with the db class
# Upgrade DB if needed
@@ -119,6 +119,7 @@ def main ():
#===============================================================================
# This is the main loop of Pi.Alert
#===============================================================================
mylog('debug', ['[Import Config TEST outside loop] lastImportedConfFile :', conf.lastImportedConfFile])
while True:
@@ -128,6 +129,7 @@ def main ():
mylog('debug', '[MAIN] Stating loop')
# re-load user configuration and plugins
mylog('debug', ['[Import Config TEST inside loop] lastImportedConfFile :', conf.lastImportedConfFile])
importConfigs(db)
# check if new version is available / only check once an hour
@@ -311,4 +313,5 @@ def main ():
# BEGIN
#===============================================================================
if __name__ == '__main__':
mylog('debug', ['[__main__] Welcome to Pi.Alert'])
sys.exit(main())