summaryrefslogtreecommitdiff
path: root/local
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2019-12-14 07:02:42 -0800
committerRobin H. Johnson <robbat2@gentoo.org>2019-12-14 07:02:42 -0800
commit68286fa5ad35ccc2ed7ef855f2f375aaa9fa3098 (patch)
tree5b47232f6fa4c26d1e4b904aa6c5625aa1c1d738 /local
parentpre-receive.gentoo-news: convert to python3 (diff)
downloadgithooks-68286fa5ad35ccc2ed7ef855f2f375aaa9fa3098.tar.gz
githooks-68286fa5ad35ccc2ed7ef855f2f375aaa9fa3098.tar.bz2
githooks-68286fa5ad35ccc2ed7ef855f2f375aaa9fa3098.zip
local/gentoo_push_notification.py: convert to python3githooks-20191214T070340
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Diffstat (limited to 'local')
-rw-r--r--local/gentoo_push_notification.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/local/gentoo_push_notification.py b/local/gentoo_push_notification.py
index f683042..374629e 100644
--- a/local/gentoo_push_notification.py
+++ b/local/gentoo_push_notification.py
@@ -1,8 +1,10 @@
-#!/usr/bin/python
+#!/usr/bin/python3
import hmac
import sys
-import urllib2
+import urllib.request
+import urllib.error
+import urllib.parse
import json
import time
@@ -48,22 +50,25 @@ def main(submit_url, hmac_key, project_name, checkout_url, timeout=None):
data["project"] = project_name
data_s = json.dumps(data)
chksum = hmac.new(hmac_key, msg=data_s).hexdigest()
- request = urllib2.Request(submit_url, data_s, {HMAC_HEADER:chksum})
+ request = urllib.request.Request(submit_url, data_s, {HMAC_HEADER:chksum})
try:
if timeout is not None:
- result = urllib2.urlopen(request, timeout=float(timeout))
+ result = urllib.request.urlopen(request, timeout=float(timeout))
else:
- result = urllib2.urlopen(request)
- except Exception, e:
- print "exception occured: %s" % (e,)
+ result = urllib.request.urlopen(request)
+ except Exception as e:
+ print("exception occured: %s" % (e,))
return 2
code = result.getcode()
if code != 200:
- print code
+ print(code)
return 1
return 0
if __name__ == '__main__':
- sys.exit(main(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4],
- timeout=sys.argv[5]))
+ sys.exit(main(sys.argv[1],
+ sys.argv[2],
+ sys.argv[3],
+ sys.argv[4],
+ timeout=sys.argv[5]))