Title: [238636] trunk/Tools
- Revision
- 238636
- Author
- aakash_j...@apple.com
- Date
- 2018-11-28 13:59:51 -0800 (Wed, 28 Nov 2018)
Log Message
[ews-app] Add support to get list of Bugzilla patches needing review
https://bugs.webkit.org/show_bug.cgi?id=191942
Reviewed by Lucas Forschler.
* BuildSlaveSupport/ews-app/ews/common/bugzilla.py:
(Bugzilla.get_list_of_patches_needing_reviews): Get list of patches needing review.
(BugzillaBeautifulSoup.fetch_attachment_ids_from_review_queue): Copied from Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py
(BugzillaBeautifulSoup._load_query): Ditto.
(BugzillaBeautifulSoup._parse_attachment_ids_request_query): Ditto.
Modified Paths
Diff
Modified: trunk/Tools/BuildSlaveSupport/ews-app/ews/common/bugzilla.py (238635 => 238636)
--- trunk/Tools/BuildSlaveSupport/ews-app/ews/common/bugzilla.py 2018-11-28 21:55:13 UTC (rev 238635)
+++ trunk/Tools/BuildSlaveSupport/ews-app/ews/common/bugzilla.py 2018-11-28 21:59:51 UTC (rev 238636)
@@ -23,8 +23,13 @@
import base64
import logging
import os
+import re
+import socket
+from datetime import datetime, timedelta
+
from ews.models.patch import Patch
+from ews.thirdparty.BeautifulSoup import BeautifulSoup, SoupStrainer
import ews.common.util as util
import ews.config as config
@@ -69,3 +74,68 @@
if not os.path.exists(config.PATCH_FOLDER):
os.mkdir(config.PATCH_FOLDER)
return config.PATCH_FOLDER + '{}.patch'.format(patch_id)
+
+ @classmethod
+ def get_list_of_patches_needing_reviews(cls):
+ current_time = datetime.today()
+ ids_needing_review = set(BugzillaBeautifulSoup().fetch_attachment_ids_from_review_queue(current_time - timedelta(7)))
+ #TODO: add security bugs support here.
+ return ids_needing_review
+
+
+class BugzillaBeautifulSoup():
+ # FIXME: Deprecate this class when https://bugzilla.mozilla.org/show_bug.cgi?id=1508531 is fixed.
+ def __init__(self):
+ self._browser = None
+
+ def _get_browser(self):
+ if not self._browser:
+ socket.setdefaulttimeout(600)
+ from mechanize import Browser
+ self._browser = Browser()
+ self._browser.set_handle_robots(False)
+ return self._browser
+
+ def _set_browser(self, value):
+ self._browser = value
+
+ browser = property(_get_browser, _set_browser)
+
+ def fetch_attachment_ids_from_review_queue(self, since=None, _only_security_bugs_=False):
+ review_queue_url = 'request.cgi?action=""
+ if only_security_bugs:
+ review_queue_url += '&product=Security'
+ return self._parse_attachment_ids_request_query(self._load_query(review_queue_url), since)
+
+ def _load_query(self, query):
+ # TODO: check if we need to authenticate.
+ full_url = '{}{}'.format(config.BUG_SERVER_URL, query)
+ _log.info('Getting list of patches needing review, URL: {}'.format(full_url))
+ return self.browser.open(full_url)
+
+ def _parse_attachment_ids_request_query(self, page, since=None):
+ # Formats
+ digits = re.compile("\d+")
+ attachment_href = re.compile("attachment.cgi\?id=\d+&action=""
+ # if no date is given, return all ids
+ if not since:
+ attachment_links = SoupStrainer("a", href=""
+ return [int(digits.search(tag["href"]).group(0))
+ for tag in BeautifulSoup(page, parseOnlyThese=attachment_links)]
+
+ # Parse the main table only
+ date_format = re.compile("\d{4}-\d{2}-\d{2} \d{2}:\d{2}")
+ mtab = SoupStrainer("table", {"class": "requests"})
+ soup = BeautifulSoup(page, parseOnlyThese=mtab)
+ patch_ids = []
+
+ for row in soup.findAll("tr"):
+ patch_tag = row.find("a", {"href": attachment_href})
+ if not patch_tag:
+ continue
+ patch_id = int(digits.search(patch_tag["href"]).group(0))
+ date_tag = row.find("td", text=date_format)
+ if date_tag and datetime.strptime(date_format.search(date_tag).group(0), "%Y-%m-%d %H:%M") < since:
+ continue
+ patch_ids.append(patch_id)
+ return patch_ids
Modified: trunk/Tools/ChangeLog (238635 => 238636)
--- trunk/Tools/ChangeLog 2018-11-28 21:55:13 UTC (rev 238635)
+++ trunk/Tools/ChangeLog 2018-11-28 21:59:51 UTC (rev 238636)
@@ -1,3 +1,16 @@
+2018-11-28 Aakash Jain <aakash_j...@apple.com>
+
+ [ews-app] Add support to get list of Bugzilla patches needing review
+ https://bugs.webkit.org/show_bug.cgi?id=191942
+
+ Reviewed by Lucas Forschler.
+
+ * BuildSlaveSupport/ews-app/ews/common/bugzilla.py:
+ (Bugzilla.get_list_of_patches_needing_reviews): Get list of patches needing review.
+ (BugzillaBeautifulSoup.fetch_attachment_ids_from_review_queue): Copied from Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py
+ (BugzillaBeautifulSoup._load_query): Ditto.
+ (BugzillaBeautifulSoup._parse_attachment_ids_request_query): Ditto.
+
2018-11-28 Daniel Bates <daba...@apple.com>
[iOS] Page not defocused when Find-in-page becomes first responder
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes