[GRASS-SVN] r65179 - grass/trunk/scripts/g.manual

svn_grass at osgeo.org svn_grass at osgeo.org
Sun May 3 04:16:40 PDT 2015


Author: martinl
Date: 2015-05-03 04:16:40 -0700 (Sun, 03 May 2015)
New Revision: 65179

Modified:
   grass/trunk/scripts/g.manual/g.manual.py
Log:
g.manual: use webbrowser package (attempt to fix g.manual on Windows)

Modified: grass/trunk/scripts/g.manual/g.manual.py
===================================================================
--- grass/trunk/scripts/g.manual/g.manual.py	2015-05-03 10:07:43 UTC (rev 65178)
+++ grass/trunk/scripts/g.manual/g.manual.py	2015-05-03 11:16:40 UTC (rev 65179)
@@ -6,7 +6,7 @@
 # AUTHOR(S):    Markus Neteler
 #               Converted to Python by Glynn Clements
 # PURPOSE:      Display the HTML/MAN pages
-# COPYRIGHT:    (C) 2003, 2008, 2010-2012 by the GRASS Development Team
+# COPYRIGHT:    (C) 2003-2015 by the GRASS Development Team
 #
 #               This program is free software under the GNU General Public
 #               License (>=v2). Read the file COPYING that comes with GRASS
@@ -49,12 +49,15 @@
 import sys
 import os
 import urllib
+import webbrowser
 
 from grass.script.utils import basename
 from grass.script import core as grass
 
 def start_browser(entry):
-    if browser != 'xdg-open' and not grass.find_program(browser):
+    if browser and \
+       browser not in ('xdg-open', 'explorer') and \
+       not grass.find_program(browser):
         grass.fatal(_("Browser '%s' not found") % browser)
 
     if flags['o']:
@@ -72,16 +75,19 @@
     
         url_path = 'file://' + path
     
+    if browser:
+        webbrowser.register(browser_name, None)
+    
     grass.verbose(_("Starting browser '%(browser)s' for manual"
-                    " entry '%(entry)s'...")
-                  % dict(browser=browser_name, entry=entry))
-
+                    " entry '%(entry)s'...") % \
+                  dict(browser=browser_name, entry=entry))
+    
     try:
-        os.execlp(browser, browser_name, url_path)
-    except OSError:
+        webbrowser.open(url_path)
+    except:
         grass.fatal(_("Error starting browser '%(browser)s' for HTML file"
                       " '%(path)s'") % dict(browser=browser, path=path))
-
+    
 def start_man(entry):
     path = os.path.join(gisbase, 'docs', 'man', 'man1', entry + '.1')
     if not os.path.exists(path) and os.getenv('GRASS_ADDON_BASE'):
@@ -111,9 +117,7 @@
         start = start_browser
     
     entry  = options['entry']
-    
     gisbase = os.environ['GISBASE']
-    
     browser = os.getenv('GRASS_HTML_BROWSER', '')
     
     if sys.platform == 'darwin':



More information about the grass-commit mailing list