aboutsummaryrefslogtreecommitdiff
path: root/steuermann
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2016-07-03 19:08:54 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2016-07-03 19:08:54 -0400
commitfbb0cc28a394e697670e27f33738f7578e604b7e (patch)
treef75d52f01e2b11c8b952e4f6626e73c67631b80c /steuermann
parentf682e2922ca10fc9b25a726344ec6276bd380d7c (diff)
downloadsteuermann-fbb0cc28a394e697670e27f33738f7578e604b7e.tar.gz
Make configuration more dynamic; stop hardcoding paths
Diffstat (limited to 'steuermann')
-rw-r--r--steuermann/config.py36
1 files changed, 32 insertions, 4 deletions
diff --git a/steuermann/config.py b/steuermann/config.py
index 3a001a7..7f8d04c 100644
--- a/steuermann/config.py
+++ b/steuermann/config.py
@@ -1,8 +1,36 @@
-db_creds = '/ssbwebv1/data2/steuermann/steuermann.db'
+from __future__ import print_function
+import os
+import sys
-def open_db() :
+_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)
+
+try:
+ sys.path.insert(1, os.path.dirname(user_config))
+ 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:
+ user_config = os.path.abspath(os.environ['STEUERMANN_CONFIG'])
+ sys.path = _sys
+ sys.path.insert(1, os.path.dirname(user_config))
+ try:
+ import config
+ except ImportError:
+ print('FATAL: Missing config (i.e. {0})'.format(user_config))
+ exit(1)
+
+
+db_creds = config.db_creds
+
+
+def open_db():
import sqlite3
return sqlite3.connect(db_creds)
-logdir = '/ssbwebv1/data2/steuermann/logs'
-host_logs = '/ssbwebv1/data2/steuermann/host_logs'
+logdir = config.logdir
+host_logs = config.host_logs