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
import sys
import httplib, urllib
import http.client, urllib.request, urllib.parse, urllib.error
import getopt
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",
urllib.urlencode({
urllib.parse.urlencode({
"token": "aNY2xeYydxzabzihTjb3P2LMHhqhr2",
"user": "uDhH33UjQQDYtNzJb1ThRiWb9ingGK",
"message": msg,
@@ -29,7 +29,7 @@ title="Nagios"
optslist, args = [], []
try:
optslist, args = getopt.getopt(sys.argv[1:], 'ht:v')
except getopt.error, cause:
except getopt.error as cause:
helpflag=True
lastyear=0
@@ -44,6 +44,6 @@ v=" ".join(args)
rc=pushover(v, title)
if verbose:
if rc:
print "delivered"
print("delivered")
else:
print "NOT delivered"
print("NOT delivered")