Fixed verbosity and quitness being overridden by config file values

This commit is contained in:
Mark Qvist 2023-01-27 17:00:29 +01:00
parent 2bb34176b7
commit a64f3a58f7

View File

@ -204,8 +204,6 @@ def program_setup(configdir = None, rnsconfigdir = None, run_pn = False, on_inbo
global lxmd_config, active_configuration, targetloglevel global lxmd_config, active_configuration, targetloglevel
global message_router, lxmf_destination global message_router, lxmf_destination
targetloglevel = 3+verbosity-quietness
if service: if service:
targetlogdest = RNS.LOG_FILE targetlogdest = RNS.LOG_FILE
targetloglevel = None targetloglevel = None
@ -234,6 +232,12 @@ def program_setup(configdir = None, rnsconfigdir = None, run_pn = False, on_inbo
if not os.path.isdir(lxmdir): if not os.path.isdir(lxmdir):
os.makedirs(lxmdir) os.makedirs(lxmdir)
if not os.path.isfile(configpath):
RNS.log("Could not load config file, creating default configuration file...")
create_default_config(configpath)
RNS.log("Default config file created. Make any necessary changes in "+configpath+" and restart lxmd if needed.")
time.sleep(1.5)
if os.path.isfile(configpath): if os.path.isfile(configpath):
try: try:
lxmd_config = ConfigObj(configpath) lxmd_config = ConfigObj(configpath)
@ -241,15 +245,16 @@ def program_setup(configdir = None, rnsconfigdir = None, run_pn = False, on_inbo
RNS.log("Could not parse the configuration at "+configpath, RNS.LOG_ERROR) RNS.log("Could not parse the configuration at "+configpath, RNS.LOG_ERROR)
RNS.log("Check your configuration file for errors!", RNS.LOG_ERROR) RNS.log("Check your configuration file for errors!", RNS.LOG_ERROR)
RNS.panic() RNS.panic()
else:
RNS.log("Could not load config file, creating default configuration file...")
create_default_config(configpath)
RNS.log("Default config file created. Make any necessary changes in "+configpath+" and restart Reticulum if needed.")
time.sleep(1.5)
apply_config() apply_config()
RNS.log("Configuration loaded from "+configpath, RNS.LOG_VERBOSE) RNS.log("Configuration loaded from "+configpath, RNS.LOG_VERBOSE)
if targetloglevel == None:
targetloglevel = 3
if verbosity != 0 or quietness != 0:
targetloglevel = targetloglevel+verbosity-quietness
# Start Reticulum # Start Reticulum
RNS.log("Substantiating Reticulum...") RNS.log("Substantiating Reticulum...")
reticulum = RNS.Reticulum(configdir=rnsconfigdir, loglevel=targetloglevel, logdest=targetlogdest) reticulum = RNS.Reticulum(configdir=rnsconfigdir, loglevel=targetloglevel, logdest=targetlogdest)