From 3280c68737b653f87dfa73afe93df65a3d0e9a42 Mon Sep 17 00:00:00 2001 From: JHCD Date: Tue, 23 Jun 2015 22:50:33 +0200 Subject: [PATCH] change exception-handling - only error-msg instead of logging.exception - second logging.debug with exec-trace --- includes/alarmHandler.py | 2 +- includes/decoder.py | 2 +- includes/descriptionList.py | 17 +++++++++++++---- includes/filter.py | 13 ++++++++----- includes/shellHeader.py | 4 ++-- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/includes/alarmHandler.py b/includes/alarmHandler.py index adb8e23..8934b81 100644 --- a/includes/alarmHandler.py +++ b/includes/alarmHandler.py @@ -32,7 +32,7 @@ def processAlarm(typ,freq,data): @requires: active plugins in pluginList @return: nothing - @exception: Exception if Alarm processing failed + @exception: Exception if Alarm processing itself failed """ try: logging.debug("[ ALARM ]") diff --git a/includes/decoder.py b/includes/decoder.py index 2161968..7814e59 100644 --- a/includes/decoder.py +++ b/includes/decoder.py @@ -21,7 +21,7 @@ def decode(freq, decoded): @param decoded: RAW Information from Multimon-NG @return: nothing - @exception: Exception if decoder File call failed + @exception: Exception if decoder file call failed """ try: # FMS Decoder Section diff --git a/includes/descriptionList.py b/includes/descriptionList.py index 6f3e0ea..ebee2bd 100644 --- a/includes/descriptionList.py +++ b/includes/descriptionList.py @@ -25,7 +25,6 @@ def loadCSV(typ, idField): Structure: [id] = description @return: Python list of descriptions - @exception: Exception if loading failed """ resultList = {} try: @@ -40,9 +39,12 @@ def loadCSV(typ, idField): resultList[row[idField]] = row['description'] logging.debug("-- loading csv finished") except: - logging.exception("loading csvList for typ: %s failed", typ) + logging.error("loading csvList for typ: %s failed", typ) + logging.debug("loading csvList for typ: %s failed", typ, exc_info=True) + raise return resultList; + ## # # call this for loading the description lists @@ -70,7 +72,9 @@ def loadDescriptionLists(): globals.ricDescribtionList = loadCSV("poc", "ric") except: - logging.exception("cannot load description lists") + logging.error("cannot load description lists") + logging.debug("cannot load description lists", exc_info=True) + pass ## @@ -95,10 +99,15 @@ def getDescription(typ, id): resultStr = globals.ricDescribtionList[id] else: logging.warning("Invalid Typ: %s", typ) + except KeyError: # will be thrown when there is no description for the id # -> nothing to do... pass + except: - logging.debug("Error during look up description lists") + logging.debug("Error during look up description lists", exc_info=True) + pass + + logging.debug(" - result for %s: %s", id, resultStr) return resultStr \ No newline at end of file diff --git a/includes/filter.py b/includes/filter.py index 4849d50..8fb9145 100644 --- a/includes/filter.py +++ b/includes/filter.py @@ -23,7 +23,6 @@ def loadFilters(): @requires: Configuration has to be set in the config.ini @return: nothing - @exception: Exception if filter loading failed """ try: logging.debug("loading filters") @@ -34,8 +33,10 @@ def loadFilters(): # insert splitet data into globals.filterList globals.filterList.append({"name": key, "typ": filter[0], "dataField": filter[1], "plugin": filter[2], "freq": freqToHz(filter[3]), "regex": filter[4]}) except: - logging.exception("cannot read config file") - + logging.error("cannot read config file") + logging.debug("cannot read config file", exc_info=True) + return + def checkFilters(typ,data,plugin,freq): """ @@ -54,7 +55,6 @@ def checkFilters(typ,data,plugin,freq): @requires: all filters in the filterList @return: nothing - @exception: Exception if filter check failed """ try: logging.debug("search Filter for %s to %s at %s Hz", typ, plugin, freq) @@ -81,4 +81,7 @@ def checkFilters(typ,data,plugin,freq): return True except: - logging.exception("Error in Filter checking") \ No newline at end of file + logging.error("Error in filter checking") + logging.debug("Error in filter checking", exc_info=True) + # something goes wrong, data will path + return True \ No newline at end of file diff --git a/includes/shellHeader.py b/includes/shellHeader.py index 8d352eb..2f105c9 100644 --- a/includes/shellHeader.py +++ b/includes/shellHeader.py @@ -18,7 +18,6 @@ def printHeader(args): @param args: All given arguments from argsparser @return: nothing - @exception: Exception if display of the shell header failed """ try: print " ____ ____ ______ __ __ __ " @@ -49,4 +48,5 @@ def printHeader(args): print "Verbose Mode!" print "" except: - logging.exception("cannot display shell header") \ No newline at end of file + logging.error("cannot display shell header") + logging.debug("cannot display shell header", exc_info=True) \ No newline at end of file