Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Catch lack of config, bail appropriately

  • Loading branch information...
commit 5021eae3fca4446a19c38ae6d62ba59d4f0ef900 1 parent 095cb46
Richo Healey richo authored

Showing 1 changed file with 16 additions and 13 deletions. Show diff stats Hide diff stats

  1. +16 13 config.py
29 config.py
@@ -42,19 +42,22 @@ def passthru(val):
42 42 ('nickserv_pass', passthru)
43 43 )
44 44
45   -with open(CONFIG_FILE) as fh:
46   - for line in fh:
47   - line = line.strip()
48   - if line.startswith("#"):
49   - # Ignore comments
50   - continue
51   - if not line:
52   - continue
53   - try:
54   - key, value = map(lambda x: x.strip(),line.split('=', 1))
55   - config[key] = value
56   - except ValueError:
57   - raise InvalidConfig, "Invalid key value pair at (FIXME Lineno)"
  45 +try:
  46 + with open(CONFIG_FILE) as fh:
  47 + for line in fh:
  48 + line = line.strip()
  49 + if line.startswith("#"):
  50 + # Ignore comments
  51 + continue
  52 + if not line:
  53 + continue
  54 + try:
  55 + key, value = map(lambda x: x.strip(),line.split('=', 1))
  56 + config[key] = value
  57 + except ValueError:
  58 + raise InvalidConfig, "Invalid key value pair at (FIXME Lineno)"
  59 +except IOError:
  60 + logging.fatal("Couldn't open %s" % (CONFIG_FILE))
58 61 if not config:
59 62 logging.error("Couldn't open config file")
60 63 raise NoConfigFile

0 comments on commit 5021eae

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