Skip to content
Permalink
Browse files

[processing] make location of GRASS 6 help files configurable

This prevents errors when algorithm help requested and there is no
access to the Internet (e.g. closed networks)
  • Loading branch information
alexbruy committed Jan 12, 2017
1 parent 161adae commit b003cbe002ab39b46387f5e8962eaf4988b545f7
@@ -80,7 +80,14 @@ def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'grass.svg'))

def help(self):
return False, 'http://grass.osgeo.org/grass64/manuals/' + self.grassName + '.html'
helpPath = GrassUtils.grassHelpPath()
if helpPath == '':
return False, None

if os.path.exists(helpPath):
return False, QUrl.fromLocalFile(os.path.join(helpPath, '{}.html'.format(self.grassName))).toString()
else:
return False, helpPath + '{}.html'.format(self.grassName)

def getParameterDescriptions(self):
descs = {}
@@ -62,6 +62,11 @@ def initializeSettings(self):
ProcessingConfig.addSetting(Setting(self.getDescription(),
GrassUtils.GRASS_LOG_CONSOLE,
self.tr('Log console output'), False))
ProcessingConfig.addSetting(Setting(
self.getDescription(),
GrassUtils.GRASS_HELP_PATH,
self.tr('Location of GRASS docs'),
GrassUtils.grassHelpPath()))

def unload(self):
AlgorithmProvider.unload(self)
@@ -70,6 +75,7 @@ def unload(self):
ProcessingConfig.removeSetting(GrassUtils.GRASS_WIN_SHELL)
ProcessingConfig.removeSetting(GrassUtils.GRASS_LOG_COMMANDS)
ProcessingConfig.removeSetting(GrassUtils.GRASS_LOG_CONSOLE)
ProcessingConfig.removeSetting(Grass7Utils.GRASS_HELP_PATH)

def createAlgsList(self):
self.preloadedAlgs = []
@@ -50,6 +50,7 @@ class GrassUtils:
GRASS_WIN_SHELL = 'GRASS_WIN_SHELL'
GRASS_LOG_COMMANDS = 'GRASS_LOG_COMMANDS'
GRASS_LOG_CONSOLE = 'GRASS_LOG_CONSOLE'
GRASS_HELP_PATH = 'GRASS_HELP_PATH'

sessionRunning = False
sessionLayers = {}
@@ -410,3 +411,27 @@ def tr(string, context=''):
if context == '':
context = 'GrassUtils'
return QCoreApplication.translate(context, string)

@staticmethod
def grassHelpPath():
helpPath = ProcessingConfig.getSetting(GrassUtils.GRASS_HELP_PATH)

if helpPath is None:
if isWindows():
localPath = os.path.join(GrassUtils.grassPath(), 'docs/html')
if os.path.exists(localPath):
helpPath = os.path.abspath(localPath)
elif isMac():
localPath = '/Applications/GRASS-6.4.app/Contents/MacOS/docs/html'
if os.path.exists(localPath):
helpPath = os.path.abspath(localPath)
else:
searchPaths = ['/usr/share/doc/grass-doc/html',
'/opt/grass/docs/html',
'/usr/share/doc/grass/docs/html']
for path in searchPaths:
if os.path.exists(path):
helpPath = os.path.abspath(path)
break

return helpPath if helpPath is not None else 'http://grass.osgeo.org/grass64/manuals/'

0 comments on commit b003cbe

Please sign in to comment.
You can’t perform that action at this time.