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