19 import http.client, urllib
25 """!A very simple Pushover client.
26 Will attempt to read the default configuration file from pushover-bash script.
30 """! Create PushoverClient instance
31 @param[in] config Configuration file to use instead of default
34 config =
"/etc/pushover/pushover-config"
37 with open(config,
"r")
as cfile:
39 key, value = line.split(
"=")
40 key = key.lower().strip()
41 self.
configconfig[key] = value.strip()
44 """!Send specified message via Pushover, optionally customising title.
45 @param[in] message Message text
46 @param[in] title If set, override message title from configuration file
50 title = self.
configconfig.get(
"title",
"SELKIELogger")
52 conn = http.client.HTTPSConnection(
"api.pushover.net:443")
56 urllib.parse.urlencode(
58 "token": self.
configconfig[
"api_token"],
59 "user": self.
configconfig[
"user_key"],
64 {
"Content-type":
"application/x-www-form-urlencoded"},
69 if __name__ ==
"__main__":
A very simple Pushover client.
def __init__(self, config=None)
Create PushoverClient instance.
def sendMessage(self, message, title=None)
Send specified message via Pushover, optionally customising title.