summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander2019-02-06 19:09:15 +0000
committerMagnus Hagander2019-02-06 19:10:42 +0000
commit6e3dc2a045b5ce331edcf052dc8a5e576c3058a8 (patch)
tree06175b3f5777deb49b1ec15caec040be99f64067
parent8ad9c43d082421adcafd52e3432ee8196ea4e6b5 (diff)
Update cmd tools to use python3
This includes changing to requests for check_patches_in_archives.py, like previously done for the internal APIs.
-rwxr-xr-xtools/commitfest/check_patches_in_archives.py41
-rwxr-xr-xtools/commitfest/update_archive_threads.py2
-rwxr-xr-xtools/mail/send_queued_mail.py2
3 files changed, 18 insertions, 27 deletions
diff --git a/tools/commitfest/check_patches_in_archives.py b/tools/commitfest/check_patches_in_archives.py
index f3c8a90..5e60175 100755
--- a/tools/commitfest/check_patches_in_archives.py
+++ b/tools/commitfest/check_patches_in_archives.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# check_patches_in_archives.py
#
@@ -9,8 +9,7 @@
import os
import sys
-import socket
-import httplib
+import requests
import magic
import logging
@@ -33,7 +32,6 @@ if __name__ == "__main__":
level=debug and logging.DEBUG or logging.INFO,
stream=sys.stdout)
- socket.setdefaulttimeout(settings.ARCHIVES_TIMEOUT)
mag = magic.open(magic.MIME)
mag.load()
@@ -48,30 +46,23 @@ if __name__ == "__main__":
url = "/message-id/attachment/%s/attach" % a.attachmentid
logging.debug("Checking attachment %s" % a.attachmentid)
- if settings.ARCHIVES_PORT != 443:
- h = httplib.HTTPConnection(host=settings.ARCHIVES_SERVER,
- port=settings.ARCHIVES_PORT,
- strict=True,
- timeout=settings.ARCHIVES_TIMEOUT)
- else:
- h = httplib.HTTPSConnection(host=settings.ARCHIVES_SERVER,
- port=settings.ARCHIVES_PORT,
- strict=True,
- timeout=settings.ARCHIVES_TIMEOUT)
- h.request('GET', url, headers={
- 'Host': settings.ARCHIVES_HOST,
- })
- resp = h.getresponse()
- if resp.status != 200:
- logging.error("Failed to get %s: %s" % (url, resp.status))
- continue
+ resp = requests.get(
+ "http{0}://{1}:{2}{3}".format(settings.ARCHIVES_PORT == 443 and 's' or '',
+ settings.ARCHIVES_SERVER,
+ settings.ARCHIVES_PORT,
+ url),
+ headers={
+ 'Host': settings.ARCHIVES_HOST,
+ },
+ timeout=settings.ARCHIVES_TIMEOUT,
+ )
- contents = resp.read()
- resp.close()
- h.close()
+ if resp.status_code != 200:
+ logging.error("Failed to get %s: %s" % (url, resp.status_code))
+ continue
# Attempt to identify the file using magic information
- mtype = mag.buffer(contents)
+ mtype = mag.buffer(resp.content)
logging.debug("Detected MIME type is %s" % mtype)
# We don't support gzipped or tar:ed patches or anything like
diff --git a/tools/commitfest/update_archive_threads.py b/tools/commitfest/update_archive_threads.py
index 59064f6..9738f25 100755
--- a/tools/commitfest/update_archive_threads.py
+++ b/tools/commitfest/update_archive_threads.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Update all attached mail threads from the archives.
#
diff --git a/tools/mail/send_queued_mail.py b/tools/mail/send_queued_mail.py
index 54848c9..d500f04 100755
--- a/tools/mail/send_queued_mail.py
+++ b/tools/mail/send_queued_mail.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Script to send off all queued email.
#