소스 검색

g.manual: use webbrowser package (fix g.manual on Windows)
(merge r65179:65180)


git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@65194 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 10 년 전
부모
커밋
3e92db1d48
4개의 변경된 파일17개의 추가작업 그리고 16개의 파일을 삭제
  1. 3 2
      lib/init/grass.py
  2. 0 2
      mswindows/env.bat
  3. 0 2
      mswindows/osgeo4w/env.bat.tmpl
  4. 14 10
      scripts/g.manual/g.manual.py

+ 3 - 2
lib/init/grass.py

@@ -475,8 +475,9 @@ def set_browser():
             browser = gfile('etc', "html_browser_mac.sh")
             os.environ['GRASS_HTML_BROWSER_MACOSX'] = "-b com.apple.helpviewer"
 
-        if windows or cygwin:
-            # MinGW startup moved to into init.bat
+        if windows:
+            browser = "start"
+        elif cygwin:
             browser = "explorer"
         else:
             # the usual suspects

+ 0 - 2
mswindows/env.bat

@@ -6,8 +6,6 @@ REM Default prompt: cmd.exe
 REM To enable bash prompt please uncomment the line bellow
 REM set GRASS_SH=%GISBASE%\msys\bin\sh.exe
 
-set GRASS_HTML_BROWSER=explorer
-
 set GRASS_PYTHON=%GISBASE%\extrabin\python.exe
 set PYTHONHOME=%GISBASE%\Python27
 

+ 0 - 2
mswindows/osgeo4w/env.bat.tmpl

@@ -7,8 +7,6 @@ REM Default prompt: cmd.exe
 REM To enable bash prompt please uncomment the line bellow
 REM set GRASS_SH=%OSGEO4W_ROOT%\apps\msys\bin\sh.exe
 
-set GRASS_HTML_BROWSER=explorer
-
 set GRASS_PYTHON=%OSGEO4W_ROOT%\bin\python.exe
 set PYTHONHOME=%OSGEO4W_ROOT%\apps\Python27
 

+ 14 - 10
scripts/g.manual/g.manual.py

@@ -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', 'start') and \
+       not grass.find_program(browser):
         grass.fatal(_("Browser '%s' not found") % browser)
 
     if flags['o']:
@@ -72,16 +75,19 @@ def start_browser(entry):
     
         url_path = 'file://' + path
     
+    if browser and browser not in ('xdg-open', 'start'):
+        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 @@ def main():
         start = start_browser
     
     entry  = options['entry']
-    
     gisbase = os.environ['GISBASE']
-    
     browser = os.getenv('GRASS_HTML_BROWSER', '')
     
     if sys.platform == 'darwin':