summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2012-03-17 14:25:02 -0500
committerSol Jerome <sol.jerome@gmail.com>2012-03-17 14:25:02 -0500
commitf76bb978a206e79704bb7e4ba3984d903c3c3ed3 (patch)
treefba7d4e28294fa56ed3d110e397aa650ae75fef5
parent21ef545abcf3d718072b404422203b039ab81c10 (diff)
downloadbcfg2-f76bb978a206e79704bb7e4ba3984d903c3c3ed3.tar.gz
bcfg2-f76bb978a206e79704bb7e4ba3984d903c3c3ed3.tar.bz2
bcfg2-f76bb978a206e79704bb7e4ba3984d903c3c3ed3.zip
Options: Better fix for unreadable bcfg2.conf
We still may be glossing over a few errors in the try/except block, but this should warn properly when bcfg2 is unable to read bcfg2.conf. Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
-rw-r--r--src/lib/Options.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/lib/Options.py b/src/lib/Options.py
index dc9818c78..2f535397f 100644
--- a/src/lib/Options.py
+++ b/src/lib/Options.py
@@ -27,12 +27,7 @@ class Option(object):
def getCFP(self):
if not self.__cfp:
self.__cfp = ConfigParser.ConfigParser()
- # FIXME: Remove this hack when except: pass below is fixed
- try:
- self.__cfp.readfp(open(self.cfpath))
- except IOError:
- e = sys.exc_info()[1]
- print("Unable to read bcfg2.conf: %s" % e)
+ self.__cfp.readfp(open(self.cfpath))
return self.__cfp
cfp = property(getCFP)
@@ -116,11 +111,7 @@ class Option(object):
self.value = self.get_cooked_value(os.environ[self.env])
return
if self.cf:
- """
- FIXME: This is masking any sort of error present in getCFP, we
- need to remove this catchall exception and figure out something
- better
- """
+ # FIXME: This is potentially masking a lot of errors
try:
self.value = self.get_cooked_value(self.cfp.get(*self.cf))
return
@@ -383,3 +374,9 @@ class OptionParser(OptionSet):
Option.cfpath = self.Bootstrap['configfile']
Option.__cfp = False
OptionSet.__init__(self, args)
+ try:
+ f = open(Option.cfpath, 'r')
+ f.close()
+ except IOError:
+ e = sys.exc_info()[1]
+ print("Warning! Unable to read specified configuration file: %s" % e)