summaryrefslogtreecommitdiff
path: root/tools/commitfest
diff options
context:
space:
mode:
authorMagnus Hagander2019-02-05 22:55:23 +0000
committerMagnus Hagander2019-02-06 09:29:00 +0000
commit463b3c1fe2e5bea061269ed9eea4b876a9eab213 (patch)
treec7f6f057b238434b4865129e2a4f61312be4d274 /tools/commitfest
parenta32f4007670330d05a834db1b67687ab8b8c3b34 (diff)
Fixes for pep8 compatibility
Diffstat (limited to 'tools/commitfest')
-rwxr-xr-xtools/commitfest/check_patches_in_archives.py100
-rwxr-xr-xtools/commitfest/oneoff/update_attachment_filenames.py100
-rwxr-xr-xtools/commitfest/update_archive_threads.py22
3 files changed, 111 insertions, 111 deletions
diff --git a/tools/commitfest/check_patches_in_archives.py b/tools/commitfest/check_patches_in_archives.py
index b8b2953..f3c8a90 100755
--- a/tools/commitfest/check_patches_in_archives.py
+++ b/tools/commitfest/check_patches_in_archives.py
@@ -26,62 +26,62 @@ from django.conf import settings
from pgcommitfest.commitfest.models import MailThreadAttachment
if __name__ == "__main__":
- debug = "--debug" in sys.argv
+ debug = "--debug" in sys.argv
- # Logging always done to stdout, but we can turn on/off how much
- logging.basicConfig(format='%(asctime)s %(levelname)s: %(msg)s',
- level=debug and logging.DEBUG or logging.INFO,
- stream=sys.stdout)
+ # Logging always done to stdout, but we can turn on/off how much
+ logging.basicConfig(format='%(asctime)s %(levelname)s: %(msg)s',
+ level=debug and logging.DEBUG or logging.INFO,
+ stream=sys.stdout)
- socket.setdefaulttimeout(settings.ARCHIVES_TIMEOUT)
- mag = magic.open(magic.MIME)
- mag.load()
+ socket.setdefaulttimeout(settings.ARCHIVES_TIMEOUT)
+ mag = magic.open(magic.MIME)
+ mag.load()
- logging.debug("Updating attachment metadata from archives")
+ logging.debug("Updating attachment metadata from archives")
- # Try to fetch/scan all attachments that haven't already been scanned.
- # If they have already been scanned, we don't bother.
- # We will hit the archives without delay when doing this, but that
- # should generally not be a problem because it's not going to be
- # downloading a lot...
- for a in MailThreadAttachment.objects.filter(ispatch=None):
- url = "/message-id/attachment/%s/attach" % a.attachmentid
- logging.debug("Checking attachment %s" % a.attachmentid)
+ # Try to fetch/scan all attachments that haven't already been scanned.
+ # If they have already been scanned, we don't bother.
+ # We will hit the archives without delay when doing this, but that
+ # should generally not be a problem because it's not going to be
+ # downloading a lot...
+ for a in MailThreadAttachment.objects.filter(ispatch=None):
+ 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
+ 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
- contents = resp.read()
- resp.close()
- h.close()
+ contents = resp.read()
+ resp.close()
+ h.close()
- # Attempt to identify the file using magic information
- mtype = mag.buffer(contents)
- logging.debug("Detected MIME type is %s" % mtype)
+ # Attempt to identify the file using magic information
+ mtype = mag.buffer(contents)
+ logging.debug("Detected MIME type is %s" % mtype)
- # We don't support gzipped or tar:ed patches or anything like
- # that at this point - just plain patches.
- if mtype.startswith('text/x-diff'):
- a.ispatch = True
- else:
- a.ispatch = False
- logging.info("Attachment %s is patch: %s" % (a.id, a.ispatch))
- a.save()
+ # We don't support gzipped or tar:ed patches or anything like
+ # that at this point - just plain patches.
+ if mtype.startswith('text/x-diff'):
+ a.ispatch = True
+ else:
+ a.ispatch = False
+ logging.info("Attachment %s is patch: %s" % (a.id, a.ispatch))
+ a.save()
- connection.close()
- logging.debug("Done.")
+ connection.close()
+ logging.debug("Done.")
diff --git a/tools/commitfest/oneoff/update_attachment_filenames.py b/tools/commitfest/oneoff/update_attachment_filenames.py
index 3ee675c..9bc1dbe 100755
--- a/tools/commitfest/oneoff/update_attachment_filenames.py
+++ b/tools/commitfest/oneoff/update_attachment_filenames.py
@@ -27,53 +27,53 @@ from django.db import connection
from commitfest.models import MailThreadAttachment
if __name__ == "__main__":
- debug = "--debug" in sys.argv
-
- # Logging always done to stdout, but we can turn on/off how much
- logging.basicConfig(format='%(asctime)s %(levelname)s: %(msg)s',
- level=debug and logging.DEBUG or logging.INFO,
- stream=sys.stdout)
-
- socket.setdefaulttimeout(settings.ARCHIVES_TIMEOUT)
- mag = magic.open(magic.MIME)
- mag.load()
-
- logging.info("Fetching attachment filenames from archives")
-
- for a in MailThreadAttachment.objects.filter(filename=""):
- url = "/message-id.json/%s" % a.messageid
- logging.debug("Checking attachment %s" % a.attachmentid)
-
- h = httplib.HTTPConnection(settings.ARCHIVES_SERVER,
- settings.ARCHIVES_PORT,
- True,
- 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
-
- contents = resp.read()
- resp.close()
- h.close()
-
- obj = simplejson.loads(contents)
-
- try:
- for msg in obj:
- for att in msg['atts']:
- if att['id'] == a.attachmentid:
- print "id %s, att id %s, filename %s" % (a.id, a.attachmentid, att['name'])
- a.filename = att['name']
- a.save()
- raise StopIteration
- logging.error("No match found for attachmentid %s" % a.attachmentid)
- except StopIteration:
- # Success
- pass
-
- connection.close()
- logging.debug("Done.")
+ debug = "--debug" in sys.argv
+
+ # Logging always done to stdout, but we can turn on/off how much
+ logging.basicConfig(format='%(asctime)s %(levelname)s: %(msg)s',
+ level=debug and logging.DEBUG or logging.INFO,
+ stream=sys.stdout)
+
+ socket.setdefaulttimeout(settings.ARCHIVES_TIMEOUT)
+ mag = magic.open(magic.MIME)
+ mag.load()
+
+ logging.info("Fetching attachment filenames from archives")
+
+ for a in MailThreadAttachment.objects.filter(filename=""):
+ url = "/message-id.json/%s" % a.messageid
+ logging.debug("Checking attachment %s" % a.attachmentid)
+
+ h = httplib.HTTPConnection(settings.ARCHIVES_SERVER,
+ settings.ARCHIVES_PORT,
+ True,
+ 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
+
+ contents = resp.read()
+ resp.close()
+ h.close()
+
+ obj = simplejson.loads(contents)
+
+ try:
+ for msg in obj:
+ for att in msg['atts']:
+ if att['id'] == a.attachmentid:
+ print "id %s, att id %s, filename %s" % (a.id, a.attachmentid, att['name'])
+ a.filename = att['name']
+ a.save()
+ raise StopIteration
+ logging.error("No match found for attachmentid %s" % a.attachmentid)
+ except StopIteration:
+ # Success
+ pass
+
+ connection.close()
+ logging.debug("Done.")
diff --git a/tools/commitfest/update_archive_threads.py b/tools/commitfest/update_archive_threads.py
index 19dd221..59064f6 100755
--- a/tools/commitfest/update_archive_threads.py
+++ b/tools/commitfest/update_archive_threads.py
@@ -22,17 +22,17 @@ from pgcommitfest.commitfest.models import MailThread
from pgcommitfest.commitfest.ajax import refresh_single_thread
if __name__ == "__main__":
- debug = "--debug" in sys.argv
+ debug = "--debug" in sys.argv
- # Logging always done to stdout, but we can turn on/off how much
- logging.basicConfig(format='%(asctime)s %(levelname)s: %(msg)s',
- level=debug and logging.DEBUG or logging.INFO,
- stream=sys.stdout)
+ # Logging always done to stdout, but we can turn on/off how much
+ logging.basicConfig(format='%(asctime)s %(levelname)s: %(msg)s',
+ level=debug and logging.DEBUG or logging.INFO,
+ stream=sys.stdout)
- logging.debug("Checking for updated mail threads in the archives")
- for thread in MailThread.objects.filter(patches__commitfests__status__in=(1,2,3)).distinct():
- logging.debug("Checking %s in the archives" % thread.messageid)
- refresh_single_thread(thread)
+ logging.debug("Checking for updated mail threads in the archives")
+ for thread in MailThread.objects.filter(patches__commitfests__status__in=(1, 2, 3)).distinct():
+ logging.debug("Checking %s in the archives" % thread.messageid)
+ refresh_single_thread(thread)
- connection.close()
- logging.debug("Done.")
+ connection.close()
+ logging.debug("Done.")