change from python to python3

This commit is contained in:
Julian Wöhrer 2022-01-01 23:02:47 +01:00
parent 5ebbaba6f1
commit d3da277d4f
15 changed files with 75 additions and 73 deletions

View file

@ -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)

View file

@ -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,

View file

@ -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,

View file

@ -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"),

View file

@ -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:

View file

@ -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)