re-format with black
This commit is contained in:
+35
-28
@@ -4,46 +4,53 @@ import sys
|
||||
import http.client, urllib.request, urllib.parse, urllib.error
|
||||
import getopt
|
||||
|
||||
|
||||
def pushover(msg, title=""):
|
||||
conn = http.client.HTTPSConnection("api.pushover.net:443")
|
||||
conn.request("POST", "/1/messages.json",
|
||||
urllib.parse.urlencode({
|
||||
"token": "aNY2xeYydxzabzihTjb3P2LMHhqhr2",
|
||||
"user": "uDhH33UjQQDYtNzJb1ThRiWb9ingGK",
|
||||
"message": msg,
|
||||
"title": title,
|
||||
}), { "Content-type": "application/x-www-form-urlencoded" })
|
||||
r1=conn.getresponse()
|
||||
#print r1.status, r1.reason
|
||||
return r1.status == 200
|
||||
conn = http.client.HTTPSConnection("api.pushover.net:443")
|
||||
conn.request(
|
||||
"POST",
|
||||
"/1/messages.json",
|
||||
urllib.parse.urlencode(
|
||||
{
|
||||
"token": "aNY2xeYydxzabzihTjb3P2LMHhqhr2",
|
||||
"user": "uDhH33UjQQDYtNzJb1ThRiWb9ingGK",
|
||||
"message": msg,
|
||||
"title": title,
|
||||
}
|
||||
),
|
||||
{"Content-type": "application/x-www-form-urlencoded"},
|
||||
)
|
||||
r1 = conn.getresponse()
|
||||
# print r1.status, r1.reason
|
||||
return r1.status == 200
|
||||
|
||||
|
||||
#
|
||||
# Main
|
||||
#
|
||||
|
||||
helpflag=False
|
||||
verbose=False
|
||||
title="Nagios"
|
||||
helpflag = False
|
||||
verbose = False
|
||||
title = "Nagios"
|
||||
|
||||
optslist, args = [], []
|
||||
try:
|
||||
optslist, args = getopt.getopt(sys.argv[1:], 'ht:v')
|
||||
optslist, args = getopt.getopt(sys.argv[1:], "ht:v")
|
||||
except getopt.error as cause:
|
||||
helpflag=True
|
||||
helpflag = True
|
||||
|
||||
lastyear=0
|
||||
for o,a in optslist:
|
||||
if o == '-v':
|
||||
verbose=True
|
||||
elif o == '-t':
|
||||
title=a
|
||||
lastyear = 0
|
||||
for o, a in optslist:
|
||||
if o == "-v":
|
||||
verbose = True
|
||||
elif o == "-t":
|
||||
title = a
|
||||
|
||||
|
||||
v=" ".join(args)
|
||||
rc=pushover(v, title)
|
||||
v = " ".join(args)
|
||||
rc = pushover(v, title)
|
||||
if verbose:
|
||||
if rc:
|
||||
print("delivered")
|
||||
else:
|
||||
print("NOT delivered")
|
||||
if rc:
|
||||
print("delivered")
|
||||
else:
|
||||
print("NOT delivered")
|
||||
|
||||
Reference in New Issue
Block a user