Christian Ebert avatar Christian Ebert committed 8bb2609

pybrowser: disable browser check on open in cygwin

BROWSER='/cygdrive/c/Program Files (x86)/Mozilla Firefox/firefox.exe'
works on cygwin, but returns False in webbrowser.open().

Comments (0)

Files changed (1)

muttils/pybrowser.py

                 url = 'file://' + url
         return url
 
-    def cygpath(self, tb):
+    def cygpath(self, tb, cygwin):
         '''Do we have to call cygpath to transform local path to windows file
         system path?'''
-        if not util.cygwin() or tb:
+        if tb or not cygwin:
             return False
         return (self.ui.app.name.find('/cygdrive/') == 0 and
                 self.ui.app.name.find('/Cygwin/') < 0)
     def urlvisit(self):
         '''Visit url(s).'''
         textbrowsers = 'w3m', 'lynx', 'links', 'elinks'
-        notty, screen = False, False
+        notty, screen, cygwin = False, False, util.cygwin()
         tb = self.appname in textbrowsers
         if tb:
             notty = not util.termconnected()
             screen = 'STY' in os.environ
-        cygpath = self.cygpath(tb)
+        cygpath = self.cygpath(tb, cygwin)
         if not self.items:
             self.items = [self.ui.configitem('net', 'homepage')]
         self.items = [self.fixurl(url, cygpath) for url in self.items]
                 util.systemcall([self.ui.app.name, url], notty, screen)
         else:
             for url in self.items:
-                if not self.ui.app.open(url):
+                if not self.ui.app.open(url) and not cygwin:
                     # BROWSER=invalid gives valid
                     # webbrowser.GenericBrowser instance
-                    # and returns False
+                    # but returns False
+                    # disable check for cygwin as valid
+                    # graphical browser instances return False too
                     raise PybrowserError
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.