Title: [222352] trunk/Tools
Revision
222352
Author
[email protected]
Date
2017-09-21 14:37:04 -0700 (Thu, 21 Sep 2017)

Log Message

webkitpy: Ignore failure to get updated selenium version
https://bugs.webkit.org/show_bug.cgi?id=177205
<rdar://problem/34531669>

Reviewed by Lucas Forschler.

Sometime asking PyPI for the latest version of Selenium fails. We should try and
fallback to, at a minimum, version 3.5.0 or a newer installed version.

* Scripts/webkitpy/thirdparty/__init__.py:
(AutoinstallImportHook.greater_than_equal_to_version): Return true if the second
version string is greater than or equal to the first version string.
(AutoinstallImportHook._install_selenium): If we can't get the latest PyPI url,
fallback to version 3.5.0 or a newer installed version.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (222351 => 222352)


--- trunk/Tools/ChangeLog	2017-09-21 21:35:47 UTC (rev 222351)
+++ trunk/Tools/ChangeLog	2017-09-21 21:37:04 UTC (rev 222352)
@@ -1,3 +1,20 @@
+2017-09-21  Jonathan Bedard  <[email protected]>
+
+        webkitpy: Ignore failure to get updated selenium version
+        https://bugs.webkit.org/show_bug.cgi?id=177205
+        <rdar://problem/34531669>
+
+        Reviewed by Lucas Forschler.
+
+        Sometime asking PyPI for the latest version of Selenium fails. We should try and
+        fallback to, at a minimum, version 3.5.0 or a newer installed version.
+
+        * Scripts/webkitpy/thirdparty/__init__.py:
+        (AutoinstallImportHook.greater_than_equal_to_version): Return true if the second
+        version string is greater than or equal to the first version string.
+        (AutoinstallImportHook._install_selenium): If we can't get the latest PyPI url,
+        fallback to version 3.5.0 or a newer installed version.
+
 2017-09-21  Filip Pizlo  <[email protected]>
 
         WSL should have some post-instantiation type checking

Modified: trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py (222351 => 222352)


--- trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py	2017-09-21 21:35:47 UTC (rev 222351)
+++ trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py	2017-09-21 21:37:04 UTC (rev 222352)
@@ -166,9 +166,31 @@
         installer.install(url="" url_subpath="Twisted-15.5.0/twisted")
         installer.install(url="" url_subpath="zope.interface-4.1.3/src/zope")
 
+    @staticmethod
+    def greater_than_equal_to_version(minimum, version):
+        for i in xrange(len(minimum.split('.'))):
+            if int(version.split('.')[i]) > int(minimum.split('.')[i]):
+                return True
+            if int(version.split('.')[i]) < int(minimum.split('.')[i]):
+                return False
+        return True
+
     def _install_selenium(self):
         self._ensure_autoinstalled_dir_is_in_sys_path()
-        url, url_subpath = self.get_latest_pypi_url('selenium')
+        try:
+            url, url_subpath = self.get_latest_pypi_url('selenium')
+        except urllib2.URLError:
+            minimum_version = '3.5.0'
+            if os.path.isfile(os.path.join(_AUTOINSTALLED_DIR, 'selenium', '__init__.py')):
+                import selenium.webdriver
+                if AutoinstallImportHook.greater_than_equal_to_version(minimum_version, selenium.webdriver.__version__):
+                    sys.stderr.write('\nFailed to find latest selenium, falling back to existing {} version\n'.format(selenium.webdriver.__version__))
+                    return
+
+            # URL for installing the minimum required version.
+            url = ''
+            url_subpath = 'selenium-{}/selenium'.format(minimum_version)
+            sys.stderr.write('\nFailed to find latest selenium, falling back to minimum {} version\n'.format(minimum_version))
         self._install(url="" url_subpath=url_subpath)
 
     def install_chromedriver(self):
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to