aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/d2/config/__init__.py6
-rw-r--r--lib/d2/util.py8
2 files changed, 11 insertions, 3 deletions
diff --git a/lib/d2/config/__init__.py b/lib/d2/config/__init__.py
index 6fa1815..98fecfb 100644
--- a/lib/d2/config/__init__.py
+++ b/lib/d2/config/__init__.py
@@ -5,7 +5,7 @@ import logging
5import logging.handlers 5import logging.handlers
6from collections import namedtuple 6from collections import namedtuple
7from dodai import Configure 7from dodai import Configure
8from d2.db import Base 8from d2 import db, util
9try: 9try:
10 from collections import OrderedDict 10 from collections import OrderedDict
11except ImportError: 11except ImportError:
@@ -30,7 +30,7 @@ class LdapConnector(object):
30 30
31 def _set_certfile(self, sections): 31 def _set_certfile(self, sections):
32 if 'certfile' in sections['ldap']: 32 if 'certfile' in sections['ldap']:
33 certfile = os.path.expanduser(sections['ldap']['certfile']) 33 certfile = util.expand_path(sections['ldap']['certfile'])
34 if os.path.exists(certfile): 34 if os.path.exists(certfile):
35 ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, certfile) 35 ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, certfile)
36 36
@@ -103,7 +103,7 @@ class Config(object):
103 # Set the schema on the db objects if any exist 103 # Set the schema on the db objects if any exist
104 if ('schema' in self.sections['db'] and 104 if ('schema' in self.sections['db'] and
105 self.sections['db']['schema']): 105 self.sections['db']['schema']):
106 for name, obj in Base.metadata.tables.items(): 106 for name, obj in db.Base.metadata.tables.items():
107 setattr(obj, 'schema', self.sections['db']['schema']) 107 setattr(obj, 'schema', self.sections['db']['schema'])
108 return self._db_ 108 return self._db_
109 109
diff --git a/lib/d2/util.py b/lib/d2/util.py
new file mode 100644
index 0000000..139ddc4
--- /dev/null
+++ b/lib/d2/util.py
@@ -0,0 +1,8 @@
1import os
2
3
4def expand_path(path):
5 """Expand the user and shell variables in a path
6 """
7 path = os.path.expanduser(path)
8 return os.path.expandvars(path)