From: Magnus Hagander Date: Wed, 6 Feb 2019 19:09:15 +0000 (+0100) Subject: Update cmd tools to use python3 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=6e3dc2a045b5ce331edcf052dc8a5e576c3058a8;p=pgcommitfest2.git Update cmd tools to use python3 This includes changing to requests for check_patches_in_archives.py, like previously done for the internal APIs. --- 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. #