From 3971ed88e85a9019e883c59d6e3ed8d21c36d6ef Mon Sep 17 00:00:00 2001 From: darksider3 Date: Fri, 20 Sep 2019 15:35:35 +0200 Subject: [PATCH] Introduce TILDE_CONF environment variable --- admin/administrate.py | 9 ++++++++- application/userapplication.py | 11 +++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/admin/administrate.py b/admin/administrate.py index 3469bbd..5761ad0 100755 --- a/admin/administrate.py +++ b/admin/administrate.py @@ -22,13 +22,20 @@ def debugExec(commands): # @TODO hardcoded config? -cwd = os.getcwd() + "/applicationsconfig.ini" +cwd = os.environ.get('TILDE_CONF') +if cwd is None: + cwd=os.getcwd()+"/applicationsconfig.ini" +else: + if os.path.isfile(cwd) is False: + cwd=os.getcwd()+"/applicationsconfig.ini" +# cwd is now either cwd/applicationsconfig or $TILDE_CONF argparser = argparse.ArgumentParser(description = 'interactive registration formular for tilde platforms') argparser.add_argument('-c', '--config', default = cwd, type = str, help = 'Path to configuration file', required = False) args = argparser.parse_args() + CONF_FILE = args.config config = configparser.ConfigParser() config.read(CONF_FILE) diff --git a/application/userapplication.py b/application/userapplication.py index 24c60a6..e1c8f06 100755 --- a/application/userapplication.py +++ b/application/userapplication.py @@ -2,12 +2,19 @@ import re, configparser, logging, sqlite3, argparse from os import getcwd - +from os import environ +from os import path as ospath import re, configparser, logging, sqlite3 try: - cwd=getcwd()+"/applicationsconfig.ini" + cwd = environ.get('TILDE_CONF') + if cwd is None: + cwd=getcwd()+"/applicationsconfig.ini" + else: + if ospath.isfile(cwd) is False: + cwd=getcwd()+"/applicationsconfig.ini" +# cwd is now either cwd/applicationsconfig or $TILDE_CONF argparser = argparse.ArgumentParser(description='interactive registration formular for tilde platforms') argparser.add_argument('-c', '--config', default=cwd, type=str, help='Config file', required=False) args = argparser.parse_args()