Revision c24ca4e8 snf-common/synnefo/settings/__init__.py
b/snf-common/synnefo/settings/__init__.py | ||
---|---|---|
33 | 33 |
|
34 | 34 |
import os |
35 | 35 |
import sys |
36 |
import glob |
|
37 |
import pkg_resources |
|
38 | 36 |
|
39 | 37 |
from synnefo.util.entry_points import extend_settings |
40 | 38 |
|
... | ... | |
50 | 48 |
|
51 | 49 |
# extend default settings with settings provided within *.conf user files |
52 | 50 |
# located in directory specified in the SYNNEFO_SETTINGS_DIR |
53 |
# environmental variable
|
|
51 |
# environment variable |
|
54 | 52 |
SYNNEFO_SETTINGS_DIR = os.environ.get('SYNNEFO_SETTINGS_DIR', "/etc/synnefo/") |
55 | 53 |
if os.path.exists(SYNNEFO_SETTINGS_DIR): |
56 |
conffiles = glob.glob(os.path.join(SYNNEFO_SETTINGS_DIR, '*.conf')) |
|
54 |
try: |
|
55 |
entries = [os.path.join(SYNNEFO_SETTINGS_DIR, x) for x in |
|
56 |
os.listdir(SYNNEFO_SETTINGS_DIR)] |
|
57 |
conffiles = [f for f in entries if os.path.isfile(f) and |
|
58 |
f.endswith(".conf")] |
|
59 |
except Exception as e: |
|
60 |
print >>sys.stderr, "Failed to list *.conf files under %s" % \ |
|
61 |
SYNNEFO_SETTINGS_DIR |
|
62 |
raise SystemExit(1) |
|
57 | 63 |
conffiles.sort() |
58 | 64 |
for f in conffiles: |
59 | 65 |
try: |
... | ... | |
61 | 67 |
except Exception as e: |
62 | 68 |
print >>sys.stderr, "Failed to read settings file: %s [%s]" % \ |
63 | 69 |
(os.path.abspath(f), e) |
64 |
|
|
65 |
|
|
70 |
raise SystemExit(1) |
Also available in: Unified diff