diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2016-07-03 19:49:53 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2016-07-03 19:50:08 -0400 |
commit | 3ceefc1fef740c4d1d9afd7c42e5bc7189b7032b (patch) | |
tree | 7e2bffb9ac945123dc10dca886b46a2f5280a32a /steuermann/config.py | |
parent | fbb0cc28a394e697670e27f33738f7578e604b7e (diff) | |
download | steuermann-3ceefc1fef740c4d1d9afd7c42e5bc7189b7032b.tar.gz |
Remove accidental use of dirname; Trap having no config whatsoever
Diffstat (limited to 'steuermann/config.py')
-rw-r--r-- | steuermann/config.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/steuermann/config.py b/steuermann/config.py index 7f8d04c..bc71955 100644 --- a/steuermann/config.py +++ b/steuermann/config.py @@ -6,23 +6,27 @@ _sys = sys.path config_dir = os.path.join(os.path.expanduser('~'), '.steuermann', 'default') user_config = os.path.join(config_dir, 'config.py') -if not os.path.exists(user_config): - os.mkdir(config_dir) +if not os.path.exists(config_dir): + os.makedirs(config_dir, mode=0o700) try: - sys.path.insert(1, os.path.dirname(user_config)) + sys.path.insert(1, config_dir) + print(sys.path) import config except ImportError: # We don't care if this config does exist, we have further options to test - if 'STEUERMANN_CONFIG' in os.environ: + try: user_config = os.path.abspath(os.environ['STEUERMANN_CONFIG']) sys.path = _sys - sys.path.insert(1, os.path.dirname(user_config)) + sys.path.insert(1, config_dir) try: import config except ImportError: print('FATAL: Missing config (i.e. {0})'.format(user_config)) exit(1) + except KeyError: + print("steuermann has not been configured yet... exiting.") + exit(1) db_creds = config.db_creds |