mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-02-11 09:44:15 +01:00
change from python to python3
This commit is contained in:
parent
5ebbaba6f1
commit
d3da277d4f
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,6 +1,7 @@
|
|||
*.psd
|
||||
*.pyc
|
||||
*.log
|
||||
*.bak
|
||||
config.ini
|
||||
log/
|
||||
|
||||
|
|
@ -11,3 +12,4 @@ log/
|
|||
\.settings/
|
||||
|
||||
\.idea/
|
||||
boswatch.py.bak
|
||||
|
|
|
|||
12
boswatch.py
12
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:
|
||||
|
|
|
|||
|
|
@ -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]")
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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():
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue