From 67a102808136462bf7fba4515f551b84b5bc35e4 Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Wed, 24 May 2017 19:20:53 +0200 Subject: [PATCH 1/5] Update doubleFilter.py Correcting the following issues (https://github.com/Schrolli91/BOSWatch/issues/217) -Consider using enumerate instead of iterating with range and len --- includes/doubleFilter.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/includes/doubleFilter.py b/includes/doubleFilter.py index 8550640..887b074 100644 --- a/includes/doubleFilter.py +++ b/includes/doubleFilter.py @@ -31,12 +31,10 @@ def checkID(typ, data, msg=""): @return: True if check was OK @return: False if double was found """ - global doubleList timestamp = int(time.time()) # Get Timestamp logging.debug("checkID: %s (%s)", data, msg) - for i in range(len(doubleList)): - (xID, xTimestamp, xMsg) = doubleList[i] + for (xID, xTimestamp, xMsg) in doubleList: # given ID found? # return False if the first entry in double_ignore_time is found, we will not check for younger ones... if data == xID and timestamp < xTimestamp + globalVars.config.getint("BOSWatch", "doubleFilter_ignore_time"): From f6d62828b8a1162973c2162d783ee1d01e88296e Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Wed, 24 May 2017 19:25:27 +0200 Subject: [PATCH 2/5] Update pynma.py Correcting the following issue (https://github.com/Schrolli91/BOSWatch/issues/217) -Using type() instead of isinstance() for a typecheck. --- includes/pynma/pynma.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/pynma/pynma.py b/includes/pynma/pynma.py index ff91a31..08a71cb 100644 --- a/includes/pynma/pynma.py +++ b/includes/pynma/pynma.py @@ -39,16 +39,16 @@ takes 2 optional arguments: self._developerkey = None self.developerkey(developerkey) if apikey: - if type(apikey) == str: + if isinstance(apikey, str): apikey = [apikey] self._apikey = uniq(apikey) def addkey(self, key): "Add a key (register ?)" - if type(key) == str: + if isinstance(key, str): if not key in self._apikey: self._apikey.append(key) - elif type(key) == list: + elif isinstance(key, list): for k in key: if not k in self._apikey: self._apikey.append(k) @@ -65,7 +65,7 @@ takes 2 optional arguments: def developerkey(self, developerkey): "Sets the developer key (and check it has the good length)" - if type(developerkey) == str and len(developerkey) == 48: + if isinstance(developerkey, str) and len(developerkey) == 48: self._developerkey = developerkey def pushWithAPIKey(self, apikey=[], application="", event="", description="", url="", contenttype=None, priority=0, batch_mode=False, html=False): From a4c9d8197f48ca6336795711563d02f4d7a2eb21 Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Wed, 24 May 2017 19:30:41 +0200 Subject: [PATCH 3/5] Update notifyMyAndroid.py Correcting the following issue (https://github.com/Schrolli91/BOSWatch/issues/217) -Using global for 'fmsAPIKeyList' but no assignment is done -Using global for 'zveiAPIKeyList' but no assignment is done -Using global for 'pocAPIKeyList' but no assignment is done --- plugins/notifyMyAndroid/notifyMyAndroid.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugins/notifyMyAndroid/notifyMyAndroid.py b/plugins/notifyMyAndroid/notifyMyAndroid.py index ece1859..7fa535f 100644 --- a/plugins/notifyMyAndroid/notifyMyAndroid.py +++ b/plugins/notifyMyAndroid/notifyMyAndroid.py @@ -173,9 +173,6 @@ def run(typ,freq,data): @return: nothing """ # local variables - global fmsAPIKeyList - global zveiAPIKeyList - global pocAPIKeyList try: try: From c3398ccd3f0ad10b10f01d25799d3236f9f55090 Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Wed, 24 May 2017 19:35:02 +0200 Subject: [PATCH 4/5] Update descriptionList.py Correcting the following issues (https://github.com/Schrolli91/BOSWatch/issues/217): -Using global for 'fmsDescribtionList' but no assignment is done -Using global for 'zveiDescribtionList' but no assignment is done -Using global for 'ricDescribtionList' but no assignment is done --- includes/descriptionList.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/includes/descriptionList.py b/includes/descriptionList.py index 848d39a..9e548fd 100644 --- a/includes/descriptionList.py +++ b/includes/descriptionList.py @@ -106,13 +106,10 @@ def getDescription(typ, data): logging.debug("look up description lists") try: if typ == "FMS": - global fmsDescribtionList resultStr = fmsDescribtionList[data] elif typ == "ZVEI": - global zveiDescribtionList resultStr = zveiDescribtionList[data] elif typ == "POC": - global ricDescribtionList resultStr = ricDescribtionList[data[:-1]] # MainRIC resultStr += " " + ricDescribtionList[data] # SubRIC else: From c9ffd6ae0dbe502c58e3b1325517ac4aaefddc35 Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Wed, 24 May 2017 19:39:22 +0200 Subject: [PATCH 5/5] Update regexFilter.py Correcting the following issue (https://github.com/Schrolli91/BOSWatch/issues/217): -Using global for 'filterList' but no assignment is done --- includes/regexFilter.py | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/regexFilter.py b/includes/regexFilter.py index 20838c8..b89c5f1 100644 --- a/includes/regexFilter.py +++ b/includes/regexFilter.py @@ -28,7 +28,6 @@ def loadFilters(): @return: nothing """ - global filterList try: logging.debug("loading filters") # For each entry in config.ini [Filters] section