summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2012-01-31 20:22:38 -0600
committerSol Jerome <sol.jerome@gmail.com>2012-02-01 09:24:32 -0600
commitb89c1678c54e161d0e6915e8d83317a24d2d89bd (patch)
tree3b64c26817a5de550f214329d075d57cfc744525
parent03ed302e9ed7c165c0b6e24ba6dad757f97110a8 (diff)
downloadbcfg2-b89c1678c54e161d0e6915e8d83317a24d2d89bd.tar.gz
bcfg2-b89c1678c54e161d0e6915e8d83317a24d2d89bd.tar.bz2
bcfg2-b89c1678c54e161d0e6915e8d83317a24d2d89bd.zip
Options: Inform user when unable to read bcfg2.conf
Reported by mattikus on IRC. The real problem here is that we are glossing over a ton of potential errors with an "except: pass" block. We need to redo this so that we catch all the potential errors and pass them on to the user. The error we were seeing in this case was caused by insufficient permissions to read the bcfg2.conf file. There is an exception that is thrown, but it was glossed over in the calling try/except block. Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
-rw-r--r--src/lib/Options.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lib/Options.py b/src/lib/Options.py
index fcd9107a9..dc9818c78 100644
--- a/src/lib/Options.py
+++ b/src/lib/Options.py
@@ -27,7 +27,12 @@ class Option(object):
def getCFP(self):
if not self.__cfp:
self.__cfp = ConfigParser.ConfigParser()
- self.__cfp.readfp(open(self.cfpath))
+ # 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)
return self.__cfp
cfp = property(getCFP)
@@ -111,6 +116,11 @@ 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
+ """
try:
self.value = self.get_cooked_value(self.cfp.get(*self.cf))
return