From 5fc61b8add1ca9ecd154ecf950a10f18ca3eca2c Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sun, 3 Jul 2016 22:28:30 -0400 Subject: A little more robust config handling --- steuermann/config.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'steuermann/config.py') diff --git a/steuermann/config.py b/steuermann/config.py index 456fab2..1c926ea 100644 --- a/steuermann/config.py +++ b/steuermann/config.py @@ -2,13 +2,13 @@ from __future__ import print_function import os import sys -_sys = sys.path +_path = sys.path.copy() config_dir = os.path.join(os.path.expanduser('~'), '.steuermann', 'default') user_config = os.path.join(config_dir, 'config.py') hosts_config = os.path.join(config_dir, 'hosts.ini') -if not os.path.exists(config_dir): - os.makedirs(config_dir, mode=0o700) +#if not os.path.exists(config_dir): +# os.makedirs(config_dir, mode=0o700) try: sys.path.insert(1, config_dir) @@ -16,12 +16,16 @@ try: except ImportError: # We don't care if this config does exist, we have further options to test try: - user_config = os.path.abspath(os.environ['STEUERMANN_CONFIG']) - sys.path = _sys + config_dir = os.path.abspath(os.environ['STEUERMANN_CONFIG']) + user_config = os.path.join(config_dir, 'config.py') + hosts_config = os.path.join(config_dir, 'hosts.ini') + + sys.path = _path sys.path.insert(1, config_dir) try: import config - except ImportError: + except ImportError as e: + print(e) print('FATAL: Missing config (i.e. {0})'.format(user_config)) exit(1) except KeyError: -- cgit