stupid exception

This commit is contained in:
age 2006-08-23 18:19:37 +00:00
parent 4f053af83a
commit 2fec1260c5

View file

@ -60,7 +60,7 @@ class CryptoBox:
format='%(asctime)s %(module)s %(levelname)s %(message)s',
stream = sys.stderr)
self.log = logging.getLogger("CryptoBox")
self.log.setLevel(logging.WARN)
self.log.setLevel(logging.INFO)
self.log.info("loggingsystem is up'n running")
## from now on everything can be logged via self.log...
except:
@ -92,11 +92,13 @@ class CryptoBox:
sys.exit(1)
try:
self.cbxPrefs = configobj.ConfigObj(config_file)
self.log.debug("found config: %s" % self.cbxPrefs.items())
# TODO/RFC: more specific exception handling, please - or (if you want to have fun) just replace the line above with the following:
# self.cbxPrefs = configobj.ConfigObj(obviouslyInvalidVariableName)
except:
self.log.error("Could not read configuration file. I give up.")
if self.cbxPrefs:
self.log.info("found config: %s" % self.cbxPrefs.items())
else:
FileNotFound = "could not find %s" % config_file
raise FileNotFound
except FileNotFound:
self.log.error(FileNotFound)
sys.exit(1)
try:
nameDB_file = os.path.join(
@ -123,8 +125,9 @@ class CryptoBox:
sys.exit(1)
try:
new_handler = logging.FileHandler(self.cbxPrefs["Log"]["Details"])
# TODO: loglevel doesn't change after first initialisation
new_handler.setLevel(getattr(logging, log_level))
# this formatter does not work for now
# TODO: this formatter does not work for now
new_handler.setFormatter = '%(asctime)s %(module)s %(levelname)s %(message)s'
self.log.addHandler(new_handler)
except IOError:
@ -157,8 +160,8 @@ class CryptoBox:
# this method just demonstrates inheritance effects - may be removed
def cbx_inheritance_test(self):
print "you lucky widow"
def cbx_inheritance_test(self, string="you lucky widow"):
self.log.info(string)
# RFC: why should CryptoBoxProps inherit CryptoBox? [l]