Changeset 58641
- Timestamp:
- Jan 8, 2014, 9:16:33 AM (11 years ago)
- File:
-
- 1 edited
-
grass/trunk/scripts/g.manual/g.manual.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
grass/trunk/scripts/g.manual/g.manual.py
r56882 r58641 35 35 #% description: Display as MAN text page instead of HTML page in browser 36 36 #%end 37 #%flag 38 #% key: o 39 #% label: Display online manuals instead of locally installed 40 #% description: Use online manuals available at http://grass.osgeo.org website. This flag has no effect when displaying MAN text pages. 41 #%end 37 42 #%option 38 43 #% key: entry … … 44 49 import sys 45 50 import os 51 import urllib 52 46 53 from grass.script import core as grass 47 54 … … 50 57 grass.fatal(_("Browser '%s' not found") % browser) 51 58 52 path = os.path.join(gisbase, 'docs', 'html', entry + '.html') 53 if not os.path.exists(path) and os.getenv('GRASS_ADDON_BASE'): 54 path = os.path.join(os.getenv('GRASS_ADDON_BASE'), 'docs', 'html', entry + '.html') 59 if flags['o']: 60 major,minor,patch = grass.version()['version'].split('.') 61 url_path = 'http://grass.osgeo.org/grass%s%s/manuals/%s.html' % (major,minor,entry) 62 if urllib.urlopen(url_path).getcode() != 200: 63 url_path = 'http://grass.osgeo.org/grass%s%s/manuals/addons/%s.html' % (major,minor,entry) 64 else: 65 path = os.path.join(gisbase, 'docs', 'html', entry + '.html') 66 if not os.path.exists(path) and os.getenv('GRASS_ADDON_BASE'): 67 path = os.path.join(os.getenv('GRASS_ADDON_BASE'), 'docs', 'html', entry + '.html') 55 68 56 if not os.path.exists(path): 57 grass.fatal(_("No HTML manual page entry for '%s'") % entry) 58 69 if not os.path.exists(path): 70 grass.fatal(_("No HTML manual page entry for '%s'") % entry) 71 72 url_path = 'file://' + path 73 59 74 grass.verbose(_("Starting browser '%(browser)s' for manual" 60 75 " entry '%(entry)s'...") … … 62 77 63 78 try: 64 os.execlp(browser, browser_name, "file://%s" % (path))79 os.execlp(browser, browser_name, url_path) 65 80 except OSError: 66 81 grass.fatal(_("Error starting browser '%(browser)s' for HTML file"
Note:
See TracChangeset
for help on using the changeset viewer.
