Skip to content

Commit

Permalink
Version 1.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
filak committed Jan 25, 2024
1 parent aec088f commit 1fc345d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
7 changes: 3 additions & 4 deletions flask-app/application/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,13 @@ def create_app(debug=False, logger=None, port=5900,
pid_counter_file = mtu.get_instance_dir(app, 'conf/pid_counter.json')
))

app.app_context().push()
### Or use: with app.app_context():
app.app_context().push()

adminConfig = mtu.getConfig(app.config['admin_config_file'], admin=True)
if not adminConfig:
return

d = mtu.getAdminConfValue(adminConfig)
d = mtu.getAdminConfValue(adminConfig, fp=app.config['admin_config_file'])
if not d:
return

Expand All @@ -99,7 +98,7 @@ def create_app(debug=False, logger=None, port=5900,
if not localConfig:
return

d = mtu.getLocalConfValue(localConfig)
d = mtu.getLocalConfValue(localConfig, fp=app.config['local_config_file'])
if not d:
return

Expand Down
21 changes: 11 additions & 10 deletions flask-app/application/modules/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@ def getConfig(cfg_file, admin=False):
config = configparser.ConfigParser()
config.read(cpath, encoding='utf-8')
return config
except:
error = 'Problem reading config file : '+ str(cfg_file)

except Exception as err:
error = 'Problem reading config file : '+ str(cfg_file) + ' : ' + str(err)
app.logger.error(error)
print('ERROR: '+error)


def getAdminConfValue(conf, worker_only=False):
def getAdminConfValue(conf, worker_only=False, fp=''):
try:
d = {}
if worker_only:
Expand All @@ -75,17 +76,17 @@ def getAdminConfValue(conf, worker_only=False):
return d

except configparser.Error as pe:
error = 'Problem parsing Admin config file : '+ app.config['admin_config_file'] + ' : ' + str(pe)
error = 'Problem parsing Admin config file : '+ fp + ' : ' + str(pe)
app.logger.error(error)
print('ERROR: '+error)

except:
error = 'Problem reading Admin config file : '+ app.config['admin_config_file']
except Exception as err:
error = 'Problem reading Admin config file : '+ fp + ' : ' + str(err)
app.logger.error(error)
print('ERROR: '+error)


def getLocalConfValue(conf):
def getLocalConfValue(conf, fp=''):
try:
d = {}
section = 'appconf'
Expand Down Expand Up @@ -154,12 +155,12 @@ def getLocalConfValue(conf):
return d

except configparser.Error as pe:
error = 'Parsing local config file : ' + app.config['local_config_file'] + ' : ' + str(pe)
error = 'Parsing local config file : ' + fp + ' : ' + str(pe)
app.logger.error(error)
print('ERROR: '+error)

except:
error = 'Problem reading local config file : '+ app.config['local_config_file']
except Exception as err:
error = 'Problem reading local config file : '+ fp + ' : ' + str(err)
app.logger.error(error)
print('ERROR: '+error)

Expand Down
5 changes: 3 additions & 2 deletions flask-app/application/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def create_app(debug=False, logger=None, port=5903,
admin_config_file = mtu.get_instance_dir(app, 'conf/mtw-admin.tmp')
))

app.app_context().push()

adminConfig = mtu.getConfig(app.config['admin_config_file'], admin=True)

if not adminConfig:
Expand All @@ -65,8 +67,7 @@ def create_app(debug=False, logger=None, port=5903,
if not localConfig:
return

with app.app_context():
d = mtu.getLocalConfValue(localConfig)
d = mtu.getLocalConfValue(localConfig)

if not d:
return
Expand Down

0 comments on commit 1fc345d

Please sign in to comment.