From d3da277d4ff546be5e27b899d6020455f440e552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20W=C3=B6hrer?= Date: Sat, 1 Jan 2022 23:02:47 +0100 Subject: [PATCH 1/5] change from python to python3 --- .gitignore | 2 + boswatch.py | 12 ++--- exampleAddOns/alarmMonitorRPi/alarmMonitor.py | 4 +- .../alarmMonitorRPi/displayServices.py | 6 +-- .../jsonSocketServer/jsonSocketServer.py | 4 +- includes/alarmHandler.py | 2 +- includes/helper/stringConverter.py | 4 +- includes/pluginLoader.py | 2 +- includes/shellHeader.py | 52 +++++++++---------- plugins/BosMon/BosMon.py | 12 ++--- plugins/Divera/Divera.py | 16 +++--- plugins/Pushover/Pushover.py | 8 +-- plugins/Sms77/Sms77.py | 8 +-- plugins/httpRequest/httpRequest.py | 14 ++--- plugins/hue/hue.py | 2 +- 15 files changed, 75 insertions(+), 73 deletions(-) diff --git a/.gitignore b/.gitignore index f37fd5c..0ab8d73 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.psd *.pyc *.log +*.bak config.ini log/ @@ -11,3 +12,4 @@ log/ \.settings/ \.idea/ +boswatch.py.bak diff --git a/boswatch.py b/boswatch.py index 8d316b6..ac59a0d 100755 --- a/boswatch.py +++ b/boswatch.py @@ -19,7 +19,7 @@ import logging import logging.handlers import argparse # for parse the args -import ConfigParser # for parse the config file +import configparser # for parse the config file import os # for log mkdir import sys # for py version import time # for time.sleep() @@ -35,7 +35,7 @@ from includes.helper import freqConverter # Check for exisiting config/config.ini-file # if not os.path.exists(os.path.dirname(os.path.abspath(__file__))+"/config/config.ini"): - print "ERROR: No config.ini found" + print("ERROR: No config.ini found") exit(1) # @@ -65,7 +65,7 @@ except SystemExit: exit(0) except: # we couldn't work without arguments -> exit - print "ERROR: cannot parsing the arguments" + print("ERROR: cannot parsing the arguments") exit(1) @@ -99,7 +99,7 @@ try: os.mkdir(globalVars.log_path) except: # we couldn't work without logging -> exit - print "ERROR: cannot initialize paths" + print("ERROR: cannot initialize paths") exit(1) # @@ -132,7 +132,7 @@ try: except: # we couldn't work without logging -> exit - print "ERROR: cannot create logger" + print("ERROR: cannot create logger") exit(1) # initialization of the logging was fine, continue... @@ -215,7 +215,7 @@ try: # try: logging.debug("reading config file") - globalVars.config = ConfigParser.ConfigParser() + globalVars.config = configparser.ConfigParser() globalVars.config.read(globalVars.script_path+"/config/config.ini") # if given loglevel is debug: if globalVars.config.getint("BOSWatch","loglevel") == 10: diff --git a/exampleAddOns/alarmMonitorRPi/alarmMonitor.py b/exampleAddOns/alarmMonitorRPi/alarmMonitor.py index f18bb15..9b5c294 100644 --- a/exampleAddOns/alarmMonitorRPi/alarmMonitor.py +++ b/exampleAddOns/alarmMonitorRPi/alarmMonitor.py @@ -27,7 +27,7 @@ RPi-Display: https://github.com/watterott/RPi-Display import logging import logging.handlers -import ConfigParser +import configparser import os import time @@ -79,7 +79,7 @@ try: # try: logging.debug("reading config file") - globalData.config = ConfigParser.SafeConfigParser() + globalData.config = configparser.SafeConfigParser() globalData.config.read("config.ini") # if given loglevel is debug: logging.debug("- [AlarmMonitor]") diff --git a/exampleAddOns/alarmMonitorRPi/displayServices.py b/exampleAddOns/alarmMonitorRPi/displayServices.py index 8badbfe..80ed83e 100644 --- a/exampleAddOns/alarmMonitorRPi/displayServices.py +++ b/exampleAddOns/alarmMonitorRPi/displayServices.py @@ -30,7 +30,7 @@ def autoTurnOffDisplay(): import sys import time import logging - import ConfigParser + import configparser import globalData logging.debug("autoTurnOffDisplay-thread started") @@ -79,7 +79,7 @@ def eventHandler(): import sys import time import logging - import ConfigParser + import configparser import pygame import globalData @@ -173,7 +173,7 @@ def displayPainter(): import sys import time import logging - import ConfigParser + import configparser import RPi.GPIO as GPIO import pygame from wrapline import wrapline diff --git a/exampleAddOns/jsonSocketServer/jsonSocketServer.py b/exampleAddOns/jsonSocketServer/jsonSocketServer.py index 5c90cd5..f4dab51 100644 --- a/exampleAddOns/jsonSocketServer/jsonSocketServer.py +++ b/exampleAddOns/jsonSocketServer/jsonSocketServer.py @@ -62,10 +62,10 @@ def siren(): if siren_stopped == True: pibrella.buzzer.stop() return True - for x in xrange(-30,30,2): + for x in range(-30,30,2): pibrella.buzzer.note(x) time.sleep(0.01) - for x in reversed(xrange(-30,30,2)): + for x in reversed(list(range(-30,30,2))): pibrella.buzzer.note(x) time.sleep(0.01) # start asynchronous siren diff --git a/includes/alarmHandler.py b/includes/alarmHandler.py index 95b6cf0..71fea6f 100644 --- a/includes/alarmHandler.py +++ b/includes/alarmHandler.py @@ -74,7 +74,7 @@ def processAlarm(typ, freq, data): # timestamp, to make sure, that all plugins use the same time data['timestamp'] = int(time.time()) # Go to all plugins in pluginList - for pluginName, plugin in globalVars.pluginList.items(): + for pluginName, plugin in list(globalVars.pluginList.items()): # if enabled use RegEx-filter if globalVars.config.getint("BOSWatch","useRegExFilter"): from includes import regexFilter diff --git a/includes/helper/stringConverter.py b/includes/helper/stringConverter.py index acd9a26..9fd555e 100644 --- a/includes/helper/stringConverter.py +++ b/includes/helper/stringConverter.py @@ -69,7 +69,7 @@ def convertToUnicode(inputString = ""): pass # 2. Check if inputString is unicode... - if isinstance(inputString, unicode): + if isinstance(inputString, str): logging.debug("-- unicode") return inputString @@ -112,7 +112,7 @@ def convertToUTF8(inputString = ""): pass # 2. Check if inputString is unicode... - if isinstance(inputString, unicode): + if isinstance(inputString, str): logging.debug("-- unicode") # ... then return it as UTF-8 uft8String = decodedString.encode('UTF-8') diff --git a/includes/pluginLoader.py b/includes/pluginLoader.py index 85f94d5..94116ae 100644 --- a/includes/pluginLoader.py +++ b/includes/pluginLoader.py @@ -13,7 +13,7 @@ import logging # Global logger import imp import os -from ConfigParser import NoOptionError # we need this exception +from configparser import NoOptionError # we need this exception from includes import globalVars # Global variables def loadPlugins(): diff --git a/includes/shellHeader.py b/includes/shellHeader.py index ab82eae..4d4d920 100644 --- a/includes/shellHeader.py +++ b/includes/shellHeader.py @@ -22,40 +22,40 @@ def printHeader(args): @return: nothing """ try: - print " ____ ____ ______ __ __ __ " - print " / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ " - print " / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ " - print " / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / " - print " /_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ " - print " German BOS Information Script " - print " by Bastian Schroll, Jens Herrmann " - print "" - print "SW Version: "+globalVars.versionNr - print "Branch: "+globalVars.branch - print "Build Date: "+globalVars.buildDate - print "" + print(" ____ ____ ______ __ __ __ ") + print(" / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ ") + print(" / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ ") + print(" / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ") + print(" /_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ ") + print(" German BOS Information Script ") + print(" by Bastian Schroll, Jens Herrmann ") + print("") + print(("SW Version: "+globalVars.versionNr)) + print(("Branch: "+globalVars.branch)) + print(("Build Date: "+globalVars.buildDate)) + print("") - print "Frequency: "+args.freq - print "Device-ID: "+str(args.device) - print "Error in PPM: "+str(args.error) - print "Active Demods: "+str(len(args.demod)) + print(("Frequency: "+args.freq)) + print(("Device-ID: "+str(args.device))) + print(("Error in PPM: "+str(args.error))) + print(("Active Demods: "+str(len(args.demod)))) if "FMS" in args.demod: - print "- FMS" + print("- FMS") if "ZVEI" in args.demod: - print "- ZVEI" + print("- ZVEI") if "POC512" in args.demod: - print "- POC512" + print("- POC512") if "POC1200" in args.demod: - print "- POC1200" + print("- POC1200") if "POC2400" in args.demod: - print "- POC2400" - print "Squelch: "+str(args.squelch) - print "Gain: "+str(args.gain) + print("- POC2400") + print(("Squelch: "+str(args.squelch))) + print(("Gain: "+str(args.gain))) if args.verbose: - print "Verbose Mode!" + print("Verbose Mode!") if args.test: - print "Test Mode!" - print "" + print("Test Mode!") + print("") except: logging.error("cannot display shell header") logging.debug("cannot display shell header", exc_info=True) diff --git a/plugins/BosMon/BosMon.py b/plugins/BosMon/BosMon.py index ac6c59f..134d3cf 100644 --- a/plugins/BosMon/BosMon.py +++ b/plugins/BosMon/BosMon.py @@ -13,8 +13,8 @@ BOSWatch-Plugin to dispatch FMS-, ZVEI- and POCSAG - messages to BosMon import logging # Global logger -import httplib #for the HTTP request -import urllib #for the HTTP request with parameters +import http.client #for the HTTP request +import urllib.request, urllib.parse, urllib.error #for the HTTP request with parameters import base64 #for the HTTP request with User/Password from includes import globalVars # Global variables @@ -115,7 +115,7 @@ def run(typ,freq,data): headers['Authorization'] = "Basic {0}".format(base64.b64encode("{0}:{1}".format(globalVars.config.get("BosMon", "bosmon_user"), globalVars.config.get("BosMon", "bosmon_password")))) logging.debug("connect to BosMon") # open connection to BosMon-Server - httprequest = httplib.HTTPConnection(globalVars.config.get("BosMon", "bosmon_server"), globalVars.config.get("BosMon", "bosmon_port"), timeout=5) + httprequest = http.client.HTTPConnection(globalVars.config.get("BosMon", "bosmon_server"), globalVars.config.get("BosMon", "bosmon_port"), timeout=5) # debug-level to shell (0=no debug|1) httprequest.set_debuglevel(0) except: @@ -149,7 +149,7 @@ def run(typ,freq,data): info = info + 4 # + b0100 # "I" is nothing to do + b0000 - params = urllib.urlencode({'type':'fms', 'address':data["fms"], 'status':data["status"], 'info':info, 'flags':'0'}) + params = urllib.parse.urlencode({'type':'fms', 'address':data["fms"], 'status':data["status"], 'info':info, 'flags':'0'}) logging.debug(" - Params: %s", params) # dispatch the BosMon-request bosMonRequest(httprequest, params, headers) @@ -161,7 +161,7 @@ def run(typ,freq,data): elif typ == "ZVEI": logging.debug("Start ZVEI to BosMon") try: - params = urllib.urlencode({'type':'zvei', 'address':data["zvei"], 'flags':'0'}) + params = urllib.parse.urlencode({'type':'zvei', 'address':data["zvei"], 'flags':'0'}) logging.debug(" - Params: %s", params) # dispatch the BosMon-request bosMonRequest(httprequest, params, headers) @@ -174,7 +174,7 @@ def run(typ,freq,data): logging.debug("Start POC to BosMon") try: # BosMon-Telegramin expected "a-d" as RIC-sub/function - params = urllib.urlencode({'type':'pocsag', 'address':data["ric"], 'flags':'0', 'function':data["functionChar"], 'message':data["msg"]}) + params = urllib.parse.urlencode({'type':'pocsag', 'address':data["ric"], 'flags':'0', 'function':data["functionChar"], 'message':data["msg"]}) logging.debug(" - Params: %s", params) # dispatch the BosMon-request bosMonRequest(httprequest, params, headers) diff --git a/plugins/Divera/Divera.py b/plugins/Divera/Divera.py index 5811f8f..dc2d46e 100644 --- a/plugins/Divera/Divera.py +++ b/plugins/Divera/Divera.py @@ -8,8 +8,8 @@ Divera-Plugin to send FMS-, ZVEI- and POCSAG - messages to Divera """ import logging # Global logger -import httplib # for the HTTP request -import urllib +import http.client # for the HTTP request +import urllib.request, urllib.parse, urllib.error from includes import globalVars # Global variables # from includes.helper import timeHandler @@ -169,9 +169,9 @@ def run(typ, freq, data): # start connection to Divera if typ == "FMS": # start the connection FMS - conn = httplib.HTTPSConnection("www.divera247.com:443") + conn = http.client.HTTPSConnection("www.divera247.com:443") conn.request("GET", "/api/fms", - urllib.urlencode({ + urllib.parse.urlencode({ "accesskey": globalVars.config.get("Divera", "accesskey"), "vehicle_ric": vehicle, "status_id": data["status"], @@ -183,9 +183,9 @@ def run(typ, freq, data): elif typ == "ZVEI": # start connection ZVEI; zvei_id in Divera is alarm-RIC! - conn = httplib.HTTPSConnection("www.divera247.com:443") + conn = http.client.HTTPSConnection("www.divera247.com:443") conn.request("GET", "/api/alarm", - urllib.urlencode({ + urllib.parse.urlencode({ "accesskey": globalVars.config.get("Divera", "accesskey"), "title": title, "ric": zvei_id, @@ -195,9 +195,9 @@ def run(typ, freq, data): elif typ == "POC": # start connection POC - conn = httplib.HTTPSConnection("www.divera247.com:443") + conn = http.client.HTTPSConnection("www.divera247.com:443") conn.request("GET", "/api/alarm", - urllib.urlencode({ + urllib.parse.urlencode({ "accesskey": globalVars.config.get("Divera", "accesskey"), "title": title, "ric": ric, diff --git a/plugins/Pushover/Pushover.py b/plugins/Pushover/Pushover.py index 4d65785..b296808 100644 --- a/plugins/Pushover/Pushover.py +++ b/plugins/Pushover/Pushover.py @@ -10,8 +10,8 @@ Pushover-Plugin to send FMS-, ZVEI- and POCSAG - messages to Pushover Clients """ import logging # Global logger -import httplib # for the HTTP request -import urllib +import http.client # for the HTTP request +import urllib.request, urllib.parse, urllib.error from includes import globalVars # Global variables # from includes.helper import timeHandler @@ -134,9 +134,9 @@ def run(typ, freq, data): sound = "pushover" # start the connection - conn = httplib.HTTPSConnection("api.pushover.net:443") + conn = http.client.HTTPSConnection("api.pushover.net:443") conn.request("POST", "/1/messages.json", - urllib.urlencode({ + urllib.parse.urlencode({ "token": globalVars.config.get("Pushover", "api_key"), "user": globalVars.config.get("Pushover", "user_key"), "message": message, diff --git a/plugins/Sms77/Sms77.py b/plugins/Sms77/Sms77.py index 6d30a1a..c6da059 100644 --- a/plugins/Sms77/Sms77.py +++ b/plugins/Sms77/Sms77.py @@ -10,8 +10,8 @@ SMS77-Plugin to send FMS-, ZVEI- and POCSAG - messages to SMS77 """ import logging # Global logger -import httplib #for the HTTP request -import urllib +import http.client #for the HTTP request +import urllib.request, urllib.parse, urllib.error from includes import globalVars # Global variables #from includes.helper import timeHandler @@ -80,9 +80,9 @@ def run(typ,freq,data): # logging.debug("send Sms77 %s", typ) - conn = httplib.HTTPSConnection("gateway.sms77.io",443) + conn = http.client.HTTPSConnection("gateway.sms77.io",443) conn.request("POST", "/api/sms", - urllib.urlencode({ + urllib.parse.urlencode({ "u": globalVars.config.get("Sms77", "user"), "p": globalVars.config.get("Sms77", "password"), "to": globalVars.config.get("Sms77", "to"), diff --git a/plugins/httpRequest/httpRequest.py b/plugins/httpRequest/httpRequest.py index 1622a8b..d0442f1 100644 --- a/plugins/httpRequest/httpRequest.py +++ b/plugins/httpRequest/httpRequest.py @@ -14,8 +14,8 @@ httpRequest-Plugin to dispatch FMS-, ZVEI- and POCSAG - messages to an URL # # Imports # -import urllib -import urllib2 +import urllib.request, urllib.parse, urllib.error +import urllib.request, urllib.error, urllib.parse import logging # Global logger from includes import globalVars # Global variables @@ -73,8 +73,8 @@ def run(typ,freq,data): # dataCopy = dict(data) for key in dataCopy: - if isinstance(dataCopy[key], basestring): - dataCopy[key] = urllib.quote(dataCopy[key]) + if isinstance(dataCopy[key], str): + dataCopy[key] = urllib.parse.quote(dataCopy[key]) # # Get URLs # @@ -100,10 +100,10 @@ def run(typ,freq,data): for url in urls: try: - urllib2.urlopen(url) - except urllib2.HTTPError as e: + urllib.request.urlopen(url) + except urllib.error.HTTPError as e: logging.warning("HTTP response: %s", e.code) - except urllib2.URLError as e: + except urllib.error.URLError as e: logging.warning("HTTP-specific error: %s", e.args) except: diff --git a/plugins/hue/hue.py b/plugins/hue/hue.py index 87f74bb..835e9f1 100644 --- a/plugins/hue/hue.py +++ b/plugins/hue/hue.py @@ -97,7 +97,7 @@ def run(typ,freq,data): logging.debug("hue REST API URL: %s", url) #blinking - for _ in xrange(repeat): + for _ in range(repeat): requests.put(url, data=data_on) logging.debug("on for %s seconds", timeon) time.sleep(timeon) From 14e415882d53e2f35be813d19c06155d2766a127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20W=C3=B6hrer?= Date: Sun, 2 Jan 2022 00:11:23 +0100 Subject: [PATCH 2/5] fix poc --- includes/decoders/poc.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index bf906fd..60d2963 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -126,15 +126,15 @@ def decode(freq, decoded): logging.debug("POCSAG Bitrate: %s", bitrate) if "Alpha:" in decoded: #check if there is a text message - poc_text = decoded.split('Alpha: ')[1].strip().replace('','').replace('','').replace('','').replace('','').strip() - if globalVars.config.getint("POC","geo_enable"): - try: - logging.debug("Using %s to find geo-tag in %s", globalVars.config.get("POC","geo_format"),poc_text) - m = re.search(globalVars.config.get("POC","geo_format"),poc_text) - if m: - logging.debug("Found geo-tag in message, parsing...") - has_geo = True - geo_order = globalVars.config.get("POC","geo_order").split(',') + poc_text = decoded.split('Alpha: ')[1].strip().replace('','').replace('','').replace('','').replace('','').strip() + if globalVars.config.getint("POC","geo_enable"): + try: + logging.debug("Using %s to find geo-tag in %s", globalVars.config.get("POC","geo_format"),poc_text) + m = re.search(globalVars.config.get("POC","geo_format"),poc_text) + if m: + logging.debug("Found geo-tag in message, parsing...") + has_geo = True + geo_order = globalVars.config.get("POC","geo_order").split(',') if geo_order[0].lower == "lon": lat = m.group(1) + "." + m.group(2) lon = m.group(3) + "." + m.group(4) From 8008c5ff9f49c767330ced563871bbf902e77545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20W=C3=B6hrer?= Date: Sun, 2 Jan 2022 00:13:14 +0100 Subject: [PATCH 3/5] fix bitrate in poc.py --- includes/decoders/poc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index 60d2963..ee162b2 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -119,7 +119,7 @@ def decode(freq, decoded): poc_id = decoded[21:28].replace(" ", "").zfill(7) poc_sub = str(int(decoded[40])+1) - if bitrate is 0: + if bitrate == 0: logging.warning("POCSAG Bitrate not found") logging.debug(" - (%s)", decoded) else: From 0a0f177b77072ac81cc23a65be313dcb840ab94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20W=C3=B6hrer?= Date: Sun, 2 Jan 2022 00:24:51 +0100 Subject: [PATCH 4/5] fix position problem in poc.py --- includes/decoders/poc.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index ee162b2..13bfcb5 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -111,13 +111,13 @@ def decode(freq, decoded): elif "POCSAG1200:" in decoded: bitrate = 1200 - poc_id = decoded[21:28].replace(" ", "").zfill(7) - poc_sub = str(int(decoded[40])+1) + poc_id = decoded[23:30].replace(" ", "").zfill(7) + poc_sub = str(int(decoded[42])+1) elif "POCSAG2400:" in decoded: bitrate = 2400 - poc_id = decoded[21:28].replace(" ", "").zfill(7) - poc_sub = str(int(decoded[40])+1) + poc_id = decoded[23:30].replace(" ", "").zfill(7) + poc_sub = str(int(decoded[42])+1) if bitrate == 0: logging.warning("POCSAG Bitrate not found") From b71db2b09425dbdd208708556f89426a4c8a1d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20W=C3=B6hrer?= Date: Sun, 2 Jan 2022 01:01:09 +0100 Subject: [PATCH 5/5] fix space errors --- plugins/FFAgent/FFAgent.py | 10 +++--- plugins/Pushover/Pushover.py | 56 +++++++++++++++--------------- plugins/gpiocontrol/gpiocontrol.py | 2 +- plugins/httpRequest/httpRequest.py | 4 +-- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/plugins/FFAgent/FFAgent.py b/plugins/FFAgent/FFAgent.py index 7ab8a92..e6d055f 100644 --- a/plugins/FFAgent/FFAgent.py +++ b/plugins/FFAgent/FFAgent.py @@ -138,11 +138,11 @@ def run(typ,freq,data): logging.debug(alarmHeaders) - alarmHeadersOrdered=OrderedDict() - alarmHeadersOrdered['webApiToken']=webApiToken - alarmHeadersOrdered['accessToken']=accessToken - alarmHeadersOrdered['selectiveCallCode']=selectiveCallCode - alarmHeadersOrdered['hmac']=hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest() + alarmHeadersOrdered=OrderedDict() + alarmHeadersOrdered['webApiToken']=webApiToken + alarmHeadersOrdered['accessToken']=accessToken + alarmHeadersOrdered['selectiveCallCode']=selectiveCallCode + alarmHeadersOrdered['hmac']=hmac.new(webApiKey, webApiToken + selectiveCallCode + accessToken + alarmData, digestmod=hashlib.sha256).hexdigest() logging.debug(alarmHeadersOrdered) diff --git a/plugins/Pushover/Pushover.py b/plugins/Pushover/Pushover.py index b296808..ed975ef 100644 --- a/plugins/Pushover/Pushover.py +++ b/plugins/Pushover/Pushover.py @@ -76,16 +76,16 @@ def run(typ, freq, data): # building message for ZVEI # if globalVars.config.get("Pushover", "zvei_sep_prio") == '1': - if data["zvei"] in globalVars.config.get("Pushover", "zvei_prio2"): - priority = '2' - elif data["zvei"] in globalVars.config.get("Pushover","zvei_prio1"): - priority = '1' - elif data["zvei"] in globalVars.config.get("Pushover","zvei_prio0"): - priority = '0' - else: - priority = '-1' - else: - priority = globalVars.config.get("Pushover","zvei_std_prio") + if data["zvei"] in globalVars.config.get("Pushover", "zvei_prio2"): + priority = '2' + elif data["zvei"] in globalVars.config.get("Pushover","zvei_prio1"): + priority = '1' + elif data["zvei"] in globalVars.config.get("Pushover","zvei_prio0"): + priority = '0' + else: + priority = '-1' + else: + priority = globalVars.config.get("Pushover","zvei_std_prio") message = globalVars.config.get("Pushover", "zvei_message") title = globalVars.config.get("Pushover", "zvei_title") @@ -98,25 +98,25 @@ def run(typ, freq, data): # logging.debug("send Pushover for %s", typ) if globalVars.config.get("Pushover", "poc_spec_ric") == '0': - if data["function"] == '1': - priority = globalVars.config.get("Pushover", "SubA") - elif data["function"] == '2': - priority = globalVars.config.get("Pushover", "SubB") - elif data["function"] == '3': - priority = globalVars.config.get("Pushover", "SubC") - elif data["function"] == '4': - priority = globalVars.config.get("Pushover", "SubD") - else: - priority = 0 + if data["function"] == '1': + priority = globalVars.config.get("Pushover", "SubA") + elif data["function"] == '2': + priority = globalVars.config.get("Pushover", "SubB") + elif data["function"] == '3': + priority = globalVars.config.get("Pushover", "SubC") + elif data["function"] == '4': + priority = globalVars.config.get("Pushover", "SubD") + else: + priority = 0 else: - if data["ric"] in globalVars.config.get("Pushover", "poc_prio2"): - priority = 2 - elif data["ric"] in globalVars.config.get("Pushover","poc_prio1"): - priority = 1 - elif data["ric"] in globalVars.config.get("Pushover","poc_prio0"): - priority = 0 - else: - priority = -1 + if data["ric"] in globalVars.config.get("Pushover", "poc_prio2"): + priority = 2 + elif data["ric"] in globalVars.config.get("Pushover","poc_prio1"): + priority = 1 + elif data["ric"] in globalVars.config.get("Pushover","poc_prio0"): + priority = 0 + else: + priority = -1 message = globalVars.config.get("Pushover", "poc_message") title = globalVars.config.get("Pushover", "poc_title") diff --git a/plugins/gpiocontrol/gpiocontrol.py b/plugins/gpiocontrol/gpiocontrol.py index 63334d1..9b7f209 100644 --- a/plugins/gpiocontrol/gpiocontrol.py +++ b/plugins/gpiocontrol/gpiocontrol.py @@ -112,7 +112,7 @@ def trigger(): GPIO.output(GPIOPIN, GPIO.LOW) logging.info("GPIOPIN %s angeschaltet", GPIOPIN) time.sleep(waitTime) - GPIO.output(GPIOPIN, GPIO.HIGH) + GPIO.output(GPIOPIN, GPIO.HIGH) logging.info("GPIOPIN %s ausgeschaltet", GPIOPIN) return diff --git a/plugins/httpRequest/httpRequest.py b/plugins/httpRequest/httpRequest.py index d0442f1..88e7b0f 100644 --- a/plugins/httpRequest/httpRequest.py +++ b/plugins/httpRequest/httpRequest.py @@ -102,9 +102,9 @@ def run(typ,freq,data): try: urllib.request.urlopen(url) except urllib.error.HTTPError as e: - logging.warning("HTTP response: %s", e.code) + logging.warning("HTTP response: %s", e.code) except urllib.error.URLError as e: - logging.warning("HTTP-specific error: %s", e.args) + logging.warning("HTTP-specific error: %s", e.args) except: logging.error("cannot send HTTP request")