move to python 3

This commit is contained in:
2019-12-16 12:04:24 -05:00
parent 5a095090a0
commit 43910bd3c4
+6 -6
View File
@@ -1,13 +1,13 @@
#!/usr/bin/python #!/usr/bin/python
import sys import sys
import httplib, urllib import http.client, urllib.request, urllib.parse, urllib.error
import getopt import getopt
def pushover(msg, title=""): def pushover(msg, title=""):
conn = httplib.HTTPSConnection("api.pushover.net:443") conn = http.client.HTTPSConnection("api.pushover.net:443")
conn.request("POST", "/1/messages.json", conn.request("POST", "/1/messages.json",
urllib.urlencode({ urllib.parse.urlencode({
"token": "aNY2xeYydxzabzihTjb3P2LMHhqhr2", "token": "aNY2xeYydxzabzihTjb3P2LMHhqhr2",
"user": "uDhH33UjQQDYtNzJb1ThRiWb9ingGK", "user": "uDhH33UjQQDYtNzJb1ThRiWb9ingGK",
"message": msg, "message": msg,
@@ -29,7 +29,7 @@ title="Nagios"
optslist, args = [], [] optslist, args = [], []
try: try:
optslist, args = getopt.getopt(sys.argv[1:], 'ht:v') optslist, args = getopt.getopt(sys.argv[1:], 'ht:v')
except getopt.error, cause: except getopt.error as cause:
helpflag=True helpflag=True
lastyear=0 lastyear=0
@@ -44,6 +44,6 @@ v=" ".join(args)
rc=pushover(v, title) rc=pushover(v, title)
if verbose: if verbose:
if rc: if rc:
print "delivered" print("delivered")
else: else:
print "NOT delivered" print("NOT delivered")