Skip to content

Commit 6e3dc2a

Browse files
committed
Update cmd tools to use python3
This includes changing to requests for check_patches_in_archives.py, like previously done for the internal APIs.
1 parent 8ad9c43 commit 6e3dc2a

File tree

3 files changed

+18
-27
lines changed

3 files changed

+18
-27
lines changed

tools/commitfest/check_patches_in_archives.py

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
#
33
# check_patches_in_archives.py
44
#
@@ -9,8 +9,7 @@
99

1010
import os
1111
import sys
12-
import socket
13-
import httplib
12+
import requests
1413
import magic
1514
import logging
1615

@@ -33,7 +32,6 @@
3332
level=debug and logging.DEBUG or logging.INFO,
3433
stream=sys.stdout)
3534

36-
socket.setdefaulttimeout(settings.ARCHIVES_TIMEOUT)
3735
mag = magic.open(magic.MIME)
3836
mag.load()
3937

@@ -48,30 +46,23 @@
4846
url = "/message-id/attachment/%s/attach" % a.attachmentid
4947
logging.debug("Checking attachment %s" % a.attachmentid)
5048

51-
if settings.ARCHIVES_PORT != 443:
52-
h = httplib.HTTPConnection(host=settings.ARCHIVES_SERVER,
53-
port=settings.ARCHIVES_PORT,
54-
strict=True,
55-
timeout=settings.ARCHIVES_TIMEOUT)
56-
else:
57-
h = httplib.HTTPSConnection(host=settings.ARCHIVES_SERVER,
58-
port=settings.ARCHIVES_PORT,
59-
strict=True,
60-
timeout=settings.ARCHIVES_TIMEOUT)
61-
h.request('GET', url, headers={
62-
'Host': settings.ARCHIVES_HOST,
63-
})
64-
resp = h.getresponse()
65-
if resp.status != 200:
66-
logging.error("Failed to get %s: %s" % (url, resp.status))
67-
continue
49+
resp = requests.get(
50+
"http{0}://{1}:{2}{3}".format(settings.ARCHIVES_PORT == 443 and 's' or '',
51+
settings.ARCHIVES_SERVER,
52+
settings.ARCHIVES_PORT,
53+
url),
54+
headers={
55+
'Host': settings.ARCHIVES_HOST,
56+
},
57+
timeout=settings.ARCHIVES_TIMEOUT,
58+
)
6859

69-
contents = resp.read()
70-
resp.close()
71-
h.close()
60+
if resp.status_code != 200:
61+
logging.error("Failed to get %s: %s" % (url, resp.status_code))
62+
continue
7263

7364
# Attempt to identify the file using magic information
74-
mtype = mag.buffer(contents)
65+
mtype = mag.buffer(resp.content)
7566
logging.debug("Detected MIME type is %s" % mtype)
7667

7768
# We don't support gzipped or tar:ed patches or anything like

tools/commitfest/update_archive_threads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
#
33
# Update all attached mail threads from the archives.
44
#

tools/mail/send_queued_mail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
#
33
# Script to send off all queued email.
44
#

0 commit comments

Comments
 (0)