Skip to content

Commit

Permalink
[GRASS] set PATH and PYTHONPATH in startModule() for t.list, #14241
Browse files Browse the repository at this point in the history
(cherry picked from commit 1d3cbd9)
  • Loading branch information
blazek committed Mar 2, 2016
1 parent 98e31ca commit 8958204
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/providers/grass/qgsgrass.cpp
Expand Up @@ -2061,14 +2061,20 @@ QProcess *QgsGrass::startModule( const QString& gisdbase, const QString& locati
out.flush();
QgsDebugMsg( gisrcFile.fileName() );
gisrcFile.close();
QStringList environment = QProcess::systemEnvironment();
environment.append( "GISRC=" + gisrcFile.fileName() );
environment.append( "GRASS_MESSAGE_FORMAT=gui" );
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QStringList paths = QgsGrass::grassModulesPaths();
// PYTHONPATH necessary for t.list.py
// PATH necessary for g.parser called by t.list.py
paths += environment.value( "PATH" ).split( QgsGrass::pathSeparator() );
environment.insert( "PATH", paths.join( QgsGrass::pathSeparator() ) );
environment.insert( "PYTHONPATH", QgsGrass::getPythonPath() );
environment.insert( "GISRC", gisrcFile.fileName() );
environment.insert( "GRASS_MESSAGE_FORMAT", "gui" );
// Normaly modules must be run in a mapset owned by user, because each module calls G_gisinit()
// which checks if G_mapset() is owned by user. The check is disabled by GRASS_SKIP_MAPSET_OWNER_CHECK.
environment.append( "GRASS_SKIP_MAPSET_OWNER_CHECK=1" );
environment.insert( "GRASS_SKIP_MAPSET_OWNER_CHECK", "1" );

process->setEnvironment( environment );
process->setProcessEnvironment( environment );

QgsDebugMsg( modulePath + " " + arguments.join( " " ) );
process->start( modulePath, arguments );
Expand Down

1 comment on commit 8958204

@blazek
Copy link
Member Author

@blazek blazek commented on 8958204 Mar 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you look in bin for the .bat?

The PATH is not added to find t.list (t.list.bat), that is already correctly found also on windows.

t.list.py calls parser() which starts g.parser (g.parser.exe) and that must be in PATH.

Please sign in to comment.