summaryrefslogtreecommitdiff
path: root/tools/utils/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/utils/common.py')
-rw-r--r--tools/utils/common.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/utils/common.py b/tools/utils/common.py
index 1a398d544..7b7811654 100644
--- a/tools/utils/common.py
+++ b/tools/utils/common.py
@@ -48,3 +48,18 @@ def LoadDBConsts(DBname, mode, serverpath):
print('LoadDBConsts: invalid database name {}'.format(DBname))
exit(1)
return consts
+
+def LoadDB(DBname, mode, serverpath):
+ filenames = [serverpath + 'db/{}/{}.conf'.format(mode, DBname)]
+
+ if os.path.isfile(serverpath + 'db/{}2.conf'.format(DBname)):
+ filenames.append(serverpath + 'db/{}2.conf'.format(DBname))
+
+ consts = dict()
+ for filename in filenames:
+ with io.open(filename) as f:
+ config = libconf.load(f)
+ db = config[DBname]
+ return db
+ print('LoadDB: invalid database name {}'.format(DBname))
+ exit(1)