aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2016-07-04 10:58:47 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2016-07-04 10:58:47 -0400
commitc38ecd205329fcc1f6056684e74f2349bde503bd (patch)
treeae65e8b4773f7a53319cdf6716acc112ad0e48f9
parentd8cb731eb631cb14cfc9274624a7518bf0daf304 (diff)
downloadsteuermann-c38ecd205329fcc1f6056684e74f2349bde503bd.tar.gz
Check for STEUERMANN_CONFIG first, then $HOME, or die
-rw-r--r--steuermann/config.py38
1 files changed, 19 insertions, 19 deletions
diff --git a/steuermann/config.py b/steuermann/config.py
index 1c926ea..5315e47 100644
--- a/steuermann/config.py
+++ b/steuermann/config.py
@@ -3,36 +3,36 @@ import os
import sys
_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)
try:
+ # We don't care if this config does exist, we have further options to test
+ config_dir = ''
+ if 'STEUERMANN_CONFIG' in os.environ:
+ 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.insert(1, config_dir)
import config
+
except ImportError:
- # We don't care if this config does exist, we have further options to test
+ 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')
+
+ sys.path = _path
+ sys.path.insert(1, config_dir)
try:
- 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 as e:
- print(e)
- print('FATAL: Missing config (i.e. {0})'.format(user_config))
- exit(1)
- except KeyError:
- print("steuermann has not been configured yet... exiting.")
+ import config
+ except ImportError as e:
+ print(e)
+ print('FATAL: Missing config (i.e. {0})'.format(user_config))
exit(1)
-
+print("Using: {0}".format(config_dir))
db_creds = config.db_creds