mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2025-12-06 07:42:03 +01:00
PEP8 changes to pushover
This commit is contained in:
parent
f92ce0d5f8
commit
cf1b5b3fc4
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -9,3 +9,5 @@ log/
|
||||||
\.pydevproject
|
\.pydevproject
|
||||||
|
|
||||||
\.settings/
|
\.settings/
|
||||||
|
|
||||||
|
\.idea/
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,15 @@ Pushover-Plugin to send FMS-, ZVEI- and POCSAG - messages to Pushover Clients
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging # Global logger
|
import logging # Global logger
|
||||||
import httplib #for the HTTP request
|
import httplib # for the HTTP request
|
||||||
import urllib
|
import urllib
|
||||||
from includes import globalVars # Global variables
|
from includes import globalVars # Global variables
|
||||||
|
|
||||||
#from includes.helper import timeHandler
|
# from includes.helper import timeHandler
|
||||||
from includes.helper import configHandler
|
from includes.helper import configHandler
|
||||||
from includes.helper import wildcardHandler
|
from includes.helper import wildcardHandler
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
#
|
#
|
||||||
# onLoad (init) function of plugin
|
# onLoad (init) function of plugin
|
||||||
|
|
@ -41,7 +42,7 @@ def onLoad():
|
||||||
# Main function of Pushover-plugin
|
# Main function of Pushover-plugin
|
||||||
# will be called by the alarmHandler
|
# will be called by the alarmHandler
|
||||||
#
|
#
|
||||||
def run(typ,freq,data):
|
def run(typ, freq, data):
|
||||||
"""
|
"""
|
||||||
This function is the implementation of the Pushover-Plugin.
|
This function is the implementation of the Pushover-Plugin.
|
||||||
It will send the data to Pushover API
|
It will send the data to Pushover API
|
||||||
|
|
@ -58,7 +59,7 @@ def run(typ,freq,data):
|
||||||
@return: nothing
|
@return: nothing
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if configHandler.checkConfig("Pushover"): #read and debug the config
|
if configHandler.checkConfig("Pushover"): # read and debug the config
|
||||||
|
|
||||||
if typ == "FMS":
|
if typ == "FMS":
|
||||||
#
|
#
|
||||||
|
|
@ -104,8 +105,8 @@ def run(typ,freq,data):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# replace the wildcards
|
# replace the wildcards
|
||||||
message = wildcardHandler.replaceWildcards(message,data)
|
message = wildcardHandler.replaceWildcards(message, data)
|
||||||
title = wildcardHandler.replaceWildcards(title,data)
|
title = wildcardHandler.replaceWildcards(title, data)
|
||||||
|
|
||||||
# start the connection
|
# start the connection
|
||||||
conn = httplib.HTTPSConnection("api.pushover.net:443")
|
conn = httplib.HTTPSConnection("api.pushover.net:443")
|
||||||
|
|
@ -119,7 +120,7 @@ def run(typ,freq,data):
|
||||||
"priority": priority,
|
"priority": priority,
|
||||||
"retry": globalVars.config.get("Pushover", "retry"),
|
"retry": globalVars.config.get("Pushover", "retry"),
|
||||||
"expire": globalVars.config.get("Pushover", "expire")
|
"expire": globalVars.config.get("Pushover", "expire")
|
||||||
}),{"Content-type": "application/x-www-form-urlencoded"})
|
}), {"Content-type": "application/x-www-form-urlencoded"})
|
||||||
|
|
||||||
except:
|
except:
|
||||||
logging.error("cannot send Pushover request")
|
logging.error("cannot send Pushover request")
|
||||||
|
|
@ -131,11 +132,11 @@ def run(typ,freq,data):
|
||||||
# check Pushover-Response
|
# check Pushover-Response
|
||||||
#
|
#
|
||||||
response = conn.getresponse()
|
response = conn.getresponse()
|
||||||
if str(response.status) == "200": #Check Pushover Response and print a Log or Error
|
if str(response.status) == "200": # Check Pushover Response and print a Log or Error
|
||||||
logging.debug("Pushover response: %s - %s" , str(response.status), str(response.reason))
|
logging.debug("Pushover response: %s - %s", str(response.status), str(response.reason))
|
||||||
else:
|
else:
|
||||||
logging.warning("Pushover response: %s - %s" , str(response.status), str(response.reason))
|
logging.warning("Pushover response: %s - %s", str(response.status), str(response.reason))
|
||||||
except: #otherwise
|
except: # otherwise
|
||||||
logging.error("cannot get Pushover response")
|
logging.error("cannot get Pushover response")
|
||||||
logging.debug("cannot get Pushover response", exc_info=True)
|
logging.debug("cannot get Pushover response", exc_info=True)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue