From b89c1678c54e161d0e6915e8d83317a24d2d89bd Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Tue, 31 Jan 2012 20:22:38 -0600 Subject: 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 --- src/lib/Options.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3-1-g7c22