aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2016-07-03 22:28:30 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2016-07-03 22:28:30 -0400
commit5fc61b8add1ca9ecd154ecf950a10f18ca3eca2c (patch)
tree7b260ed2b4c0f8905938b4f1e24398ad659d53bf
parent08eff1e00e2a7036a9c05580fa0327ef9fcfe2d1 (diff)
downloadsteuermann-5fc61b8add1ca9ecd154ecf950a10f18ca3eca2c.tar.gz
A little more robust config handling
-rw-r--r--steuermann/config.py16
1 files changed, 10 insertions, 6 deletions
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: