2010-06-04 Tony Gentilcore <tonyg@chromium.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Jun 2010 08:55:52 +0000 (08:55 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Jun 2010 08:55:52 +0000 (08:55 +0000)
        Reviewed by Adam Barth.

        Detect whether the user's environment can open a browser.
        https://bugs.webkit.org/show_bug.cgi?id=40136

        Some environments like cygwin silently fail webbrowser.open() causing
        webkit-patch upload not to display any diff. This detects environments
        where webbrowser.open() would fail by testing if webbrowser.get()
        raises an exception.

        * Scripts/webkitpy/common/system/user.py:
        * Scripts/webkitpy/tool/mocktool.py:
        * Scripts/webkitpy/tool/steps/confirmdiff.py:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@60666 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKitTools/ChangeLog
WebKitTools/Scripts/webkitpy/common/system/user.py
WebKitTools/Scripts/webkitpy/tool/mocktool.py
WebKitTools/Scripts/webkitpy/tool/steps/confirmdiff.py

index 2288fdd..2776634 100644 (file)
@@ -1,3 +1,19 @@
+2010-06-04  Tony Gentilcore  <tonyg@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Detect whether the user's environment can open a browser.
+        https://bugs.webkit.org/show_bug.cgi?id=40136
+
+        Some environments like cygwin silently fail webbrowser.open() causing
+        webkit-patch upload not to display any diff. This detects environments
+        where webbrowser.open() would fail by testing if webbrowser.get()
+        raises an exception.
+
+        * Scripts/webkitpy/common/system/user.py:
+        * Scripts/webkitpy/tool/mocktool.py:
+        * Scripts/webkitpy/tool/steps/confirmdiff.py:
+
 2010-06-03  Tony Gentilcore  <tonyg@chromium.org>
 
         Reviewed by David Levin.
index 82fa0d3..b4df3cb 100644 (file)
@@ -104,5 +104,14 @@ class User(object):
         response = raw_input("%s [Y/n]: " % message)
         return not response or response.lower() == "y"
 
+    def can_open_url(self):
+        try:
+            webbrowser.get()
+            return True
+        except webbrowser.Error, e:
+            return False
+
     def open_url(self, url):
+        if not self.can_open_url():
+            _log.warn("Failed to open %s" % url)
         webbrowser.open(url)
index 8ea6756..133c356 100644 (file)
@@ -459,6 +459,9 @@ class MockUser(object):
     def confirm(self, message=None):
         return True
 
+    def can_open_url(self):
+        return True
+
     def open_url(self, url):
         if url.startswith("file://"):
             log("MOCK: user.open_url: file://...")
index 626fcf3..7e8e348 100644 (file)
@@ -46,6 +46,9 @@ class ConfirmDiff(AbstractStep):
         ]
 
     def _show_pretty_diff(self, diff):
+        if not self._tool.user.can_open_url():
+            return None
+
         try:
             pretty_patch = PrettyPatch(self._tool.executive,
                                        self._tool.scm().checkout_root)