Skip to content
Browse files

Catch lack of config, bail appropriately

  • Loading branch information...
1 parent 095cb46 commit 5021eae3fca4446a19c38ae6d62ba59d4f0ef900 @richo richo committed Sep 25, 2011
Showing with 16 additions and 13 deletions.
  1. +16 −13 config.py
View
29 config.py
@@ -42,19 +42,22 @@ def passthru(val):
('nickserv_pass', passthru)
)
-with open(CONFIG_FILE) as fh:
- for line in fh:
- line = line.strip()
- if line.startswith("#"):
- # Ignore comments
- continue
- if not line:
- continue
- try:
- key, value = map(lambda x: x.strip(),line.split('=', 1))
- config[key] = value
- except ValueError:
- raise InvalidConfig, "Invalid key value pair at (FIXME Lineno)"
+try:
+ with open(CONFIG_FILE) as fh:
+ for line in fh:
+ line = line.strip()
+ if line.startswith("#"):
+ # Ignore comments
+ continue
+ if not line:
+ continue
+ try:
+ key, value = map(lambda x: x.strip(),line.split('=', 1))
+ config[key] = value
+ except ValueError:
+ raise InvalidConfig, "Invalid key value pair at (FIXME Lineno)"
+except IOError:
+ logging.fatal("Couldn't open %s" % (CONFIG_FILE))
if not config:
logging.error("Couldn't open config file")
raise NoConfigFile

0 comments on commit 5021eae

Please sign in to comment.
Something went wrong with that request. Please try again.