Title: [229296] trunk/Tools
Revision
229296
Author
aakash_j...@apple.com
Date
2018-03-05 17:30:37 -0800 (Mon, 05 Mar 2018)

Log Message

[webkitpy] Bugzilla class should use NetworkTransaction for network operations
https://bugs.webkit.org/show_bug.cgi?id=183222

Reviewed by Alexey Proskuryakov.

* Scripts/webkitpy/common/net/bugzilla/bugzilla.py:
(Bugzilla.open_url): Method which uses NetworkTransaction for opening url.
(Bugzilla.fetch_user): Used self.open_url instead of directly calling browser.open().
(Bugzilla.add_user_to_groups): Ditto.
(Bugzilla._fetch_bug_page): Ditto.
(Bugzilla.fetch_attachment_contents): Ditto.
(Bugzilla.get_bug_id_for_attachment_id): Ditto.
(Bugzilla.authenticate): Ditto.
(Bugzilla.add_attachment_to_bug): Ditto.
(Bugzilla.add_patch_to_bug): Ditto.
(Bugzilla.create_bug): Ditto.
(Bugzilla.clear_attachment_flags): Ditto.
(Bugzilla.set_flag_on_attachment): Ditto.
(Bugzilla.obsolete_attachment): Ditto.
(Bugzilla.add_cc_to_bug): Ditto.
(Bugzilla.post_comment_to_bug): Ditto.
(Bugzilla.close_bug_as_fixed): Ditto.
(Bugzilla.reassign_bug): Ditto.
(Bugzilla.reopen_bug): Ditto.
(Bugzilla._fetch_bug_page_by_url): Deleted, not required anymore.
* Scripts/webkitpy/common/net/networktransaction.py:
(NetworkTransaction.run): Added a FIXME.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (229295 => 229296)


--- trunk/Tools/ChangeLog	2018-03-06 00:24:20 UTC (rev 229295)
+++ trunk/Tools/ChangeLog	2018-03-06 01:30:37 UTC (rev 229296)
@@ -1,3 +1,33 @@
+2018-03-05  Aakash Jain  <aakash_j...@apple.com>
+
+        [webkitpy] Bugzilla class should use NetworkTransaction for network operations
+        https://bugs.webkit.org/show_bug.cgi?id=183222
+
+        Reviewed by Alexey Proskuryakov.
+
+        * Scripts/webkitpy/common/net/bugzilla/bugzilla.py:
+        (Bugzilla.open_url): Method which uses NetworkTransaction for opening url.
+        (Bugzilla.fetch_user): Used self.open_url instead of directly calling browser.open().
+        (Bugzilla.add_user_to_groups): Ditto.
+        (Bugzilla._fetch_bug_page): Ditto.
+        (Bugzilla.fetch_attachment_contents): Ditto.
+        (Bugzilla.get_bug_id_for_attachment_id): Ditto.
+        (Bugzilla.authenticate): Ditto.
+        (Bugzilla.add_attachment_to_bug): Ditto.
+        (Bugzilla.add_patch_to_bug): Ditto.
+        (Bugzilla.create_bug): Ditto.
+        (Bugzilla.clear_attachment_flags): Ditto.
+        (Bugzilla.set_flag_on_attachment): Ditto.
+        (Bugzilla.obsolete_attachment): Ditto.
+        (Bugzilla.add_cc_to_bug): Ditto.
+        (Bugzilla.post_comment_to_bug): Ditto.
+        (Bugzilla.close_bug_as_fixed): Ditto.
+        (Bugzilla.reassign_bug): Ditto.
+        (Bugzilla.reopen_bug): Ditto.
+        (Bugzilla._fetch_bug_page_by_url): Deleted, not required anymore.
+        * Scripts/webkitpy/common/net/networktransaction.py:
+        (NetworkTransaction.run): Added a FIXME.
+
 2018-03-05  Joseph Pecoraro  <pecor...@apple.com>
 
         dump-class-layout mishandles duplicates base classes and miscomputes padding

Modified: trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py (229295 => 229296)


--- trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py	2018-03-06 00:24:20 UTC (rev 229295)
+++ trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py	2018-03-06 01:30:37 UTC (rev 229296)
@@ -328,14 +328,17 @@
     def setdefaulttimeout(self, value):
         socket.setdefaulttimeout(value)
 
+    def open_url(self, url):
+        return NetworkTransaction().run(lambda: self.browser.open(url))
+
     def fetch_user(self, user_id):
         self.authenticate()
-        edit_user_page = self.browser.open(self.edit_user_url_for_id(user_id))
+        edit_user_page = self.open_url(self.edit_user_url_for_id(user_id))
         return self.edit_user_parser.user_dict_from_edit_user_page(edit_user_page)
 
     def add_user_to_groups(self, user_id, group_names):
         self.authenticate()
-        user_edit_page = self.browser.open(self.edit_user_url_for_id(user_id))
+        user_edit_page = self.open_url(self.edit_user_url_for_id(user_id))
         self.browser.select_form(nr=1)
         for group_name in group_names:
             group_string = self.edit_user_parser.group_string_from_name(user_edit_page, group_name)
@@ -469,11 +472,8 @@
     def _fetch_bug_page(self, bug_id):
         bug_url = self.bug_url_for_bug_id(bug_id, xml=True)
         _log.info("Fetching: %s" % bug_url)
-        return NetworkTransaction().run(lambda: self._fetch_bug_page_by_url(bug_url))
+        return self.open_url(bug_url)
 
-    def _fetch_bug_page_by_url(self, bug_url):
-        return self.browser.open(bug_url)
-
     def fetch_bug_dictionary(self, bug_id):
         try:
             self.authenticate()
@@ -488,9 +488,10 @@
 
     def fetch_attachment_contents(self, attachment_id):
         attachment_url = self.attachment_url_for_id(attachment_id)
+        _log.info("Fetching: %s" % attachment_url)
         # We need to authenticate to download patches from security bugs.
         self.authenticate()
-        return self.browser.open(attachment_url).read()
+        return self.open_url(attachment_url).read()
 
     def _parse_bug_id_from_attachment_page(self, page):
         # The "Up" relation happens to point to the bug.
@@ -512,7 +513,7 @@
 
         attachment_url = self.attachment_url_for_id(attachment_id, 'edit')
         _log.info("Fetching: %s" % attachment_url)
-        page = self.browser.open(attachment_url)
+        page = self.open_url(attachment_url)
         return self._parse_bug_id_from_attachment_page(page)
 
     # FIXME: This should just return Attachment(id), which should be able to
@@ -545,7 +546,7 @@
             username, password = credentials.read_credentials(use_stored_credentials=attempts == 1)
 
             _log.info("Logging in as %s..." % username)
-            self.browser.open(config_urls.bug_server_url +
+            self.open_url(config_urls.bug_server_url +
                               "index.cgi?GoAheadAndLogIn=1")
             self.browser.select_form(name="login")
             self.browser['Bugzilla_login'] = username
@@ -621,7 +622,7 @@
     def add_attachment_to_bug(self, bug_id, file_or_string, description, filename=None, comment_text=None, mimetype=None):
         self.authenticate()
         _log.info('Adding attachment "%s" to %s' % (description, self.bug_url_for_bug_id(bug_id)))
-        self.browser.open(self.add_attachment_url(bug_id))
+        self.open_url(self.add_attachment_url(bug_id))
         self.browser.select_form(name="entryform")
         file_object = self._file_object_for_upload(file_or_string)
         filename = filename or self._filename_for_upload(file_object, bug_id)
@@ -652,7 +653,7 @@
         self.authenticate()
         _log.info('Adding patch "%s" to %s' % (description, self.bug_url_for_bug_id(bug_id)))
 
-        self.browser.open(self.add_attachment_url(bug_id))
+        self.open_url(self.add_attachment_url(bug_id))
         self.browser.select_form(name="entryform")
         file_object = self._file_object_for_upload(file_or_string)
         filename = self._filename_for_upload(file_object, bug_id, extension="patch")
@@ -708,7 +709,7 @@
         self.authenticate()
 
         _log.info('Creating bug with title "%s"' % bug_title)
-        self.browser.open(config_urls.bug_server_url + "enter_bug.cgi?product=WebKit")
+        self.open_url(config_urls.bug_server_url + "enter_bug.cgi?product=WebKit")
         self.browser.select_form(name="Create")
         component_items = self.browser.find_control('component').items
         component_names = map(lambda item: item.name, component_items)
@@ -769,7 +770,7 @@
             comment_text += "\n\n%s" % additional_comment_text
         _log.info(comment_text)
 
-        self.browser.open(self.attachment_url_for_id(attachment_id, 'edit'))
+        self.open_url(self.attachment_url_for_id(attachment_id, 'edit'))
         self.browser.select_form(nr=1)
         self.browser.set_value(comment_text, name='comment', nr=1)
         self._find_select_element_for_flag('review').value = ("X",)
@@ -786,7 +787,7 @@
 
         self.authenticate()
         _log.info(comment_text)
-        self.browser.open(self.attachment_url_for_id(attachment_id, 'edit'))
+        self.open_url(self.attachment_url_for_id(attachment_id, 'edit'))
         self.browser.select_form(nr=1)
 
         if comment_text:
@@ -802,7 +803,7 @@
         self.authenticate()
 
         _log.info("Obsoleting attachment: %s" % attachment_id)
-        self.browser.open(self.attachment_url_for_id(attachment_id, 'edit'))
+        self.open_url(self.attachment_url_for_id(attachment_id, 'edit'))
         self.browser.select_form(nr=1)
         self.browser.find_control('isobsolete').items[0].selected = True
         # Also clear any review flag (to remove it from review/commit queues)
@@ -819,7 +820,7 @@
         self.authenticate()
 
         _log.info("Adding %s to the CC list for bug %s" % (email_address_list, bug_id))
-        self.browser.open(self.bug_url_for_bug_id(bug_id))
+        self.open_url(self.bug_url_for_bug_id(bug_id))
         self.browser.select_form(name="changeform")
         self.browser["newcc"] = ", ".join(email_address_list)
         self.browser.submit()
@@ -828,7 +829,7 @@
         self.authenticate()
 
         _log.info("Adding comment to bug %s" % bug_id)
-        self.browser.open(self.bug_url_for_bug_id(bug_id))
+        self.open_url(self.bug_url_for_bug_id(bug_id))
         self.browser.select_form(name="changeform")
         self.browser["comment"] = comment_text
         if cc:
@@ -839,7 +840,7 @@
         self.authenticate()
 
         _log.info("Closing bug %s as fixed" % bug_id)
-        self.browser.open(self.bug_url_for_bug_id(bug_id))
+        self.open_url(self.bug_url_for_bug_id(bug_id))
         self.browser.select_form(name="changeform")
         if comment_text:
             self.browser['comment'] = comment_text
@@ -857,7 +858,7 @@
             assignee = self.username
 
         _log.info("Assigning bug %s to %s" % (bug_id, assignee))
-        self.browser.open(self.bug_url_for_bug_id(bug_id))
+        self.open_url(self.bug_url_for_bug_id(bug_id))
         self.browser.select_form(name="changeform")
 
         if not self._has_control(self.browser, "assigned_to"):
@@ -878,7 +879,7 @@
         # Bugzilla requires a comment when re-opening a bug, so we know it will
         # never be None.
         _log.info(comment_text)
-        self.browser.open(self.bug_url_for_bug_id(bug_id))
+        self.open_url(self.bug_url_for_bug_id(bug_id))
         self.browser.select_form(name="changeform")
         bug_status = self.browser.find_control("bug_status", type="select")
         # This is a hack around the fact that ClientForm.ListControl seems to

Modified: trunk/Tools/Scripts/webkitpy/common/net/networktransaction.py (229295 => 229296)


--- trunk/Tools/Scripts/webkitpy/common/net/networktransaction.py	2018-03-06 00:24:20 UTC (rev 229295)
+++ trunk/Tools/Scripts/webkitpy/common/net/networktransaction.py	2018-03-06 01:30:37 UTC (rev 229296)
@@ -59,6 +59,7 @@
                 self._sleep()
             except urllib2.URLError as e:
                 self._check_for_timeout()
+                # FIXME: Log the URL which resulted in URLError.
                 _log.warn("Received URLError: {}. Retrying in {} seconds...".format(e.reason, self._backoff_seconds))
                 self._sleep()
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to