Skip to content

Commit 1d3cbd9

Browse files
committedMar 2, 2016
[GRASS] set PATH and PYTHONPATH in startModule() for t.list, #14241
1 parent 1cdffd3 commit 1d3cbd9

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed
 

‎src/providers/grass/qgsgrass.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,14 +2061,20 @@ QProcess *QgsGrass::startModule( const QString& gisdbase, const QString& locati
20612061
out.flush();
20622062
QgsDebugMsg( gisrcFile.fileName() );
20632063
gisrcFile.close();
2064-
QStringList environment = QProcess::systemEnvironment();
2065-
environment.append( "GISRC=" + gisrcFile.fileName() );
2066-
environment.append( "GRASS_MESSAGE_FORMAT=gui" );
2064+
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
2065+
QStringList paths = QgsGrass::grassModulesPaths();
2066+
// PYTHONPATH necessary for t.list.py
2067+
// PATH necessary for g.parser called by t.list.py
2068+
paths += environment.value( "PATH" ).split( QgsGrass::pathSeparator() );
2069+
environment.insert( "PATH", paths.join( QgsGrass::pathSeparator() ) );
2070+
environment.insert( "PYTHONPATH", QgsGrass::getPythonPath() );
2071+
environment.insert( "GISRC", gisrcFile.fileName() );
2072+
environment.insert( "GRASS_MESSAGE_FORMAT", "gui" );
20672073
// Normaly modules must be run in a mapset owned by user, because each module calls G_gisinit()
20682074
// which checks if G_mapset() is owned by user. The check is disabled by GRASS_SKIP_MAPSET_OWNER_CHECK.
2069-
environment.append( "GRASS_SKIP_MAPSET_OWNER_CHECK=1" );
2075+
environment.insert( "GRASS_SKIP_MAPSET_OWNER_CHECK", "1" );
20702076

2071-
process->setEnvironment( environment );
2077+
process->setProcessEnvironment( environment );
20722078

20732079
QgsDebugMsg( modulePath + " " + arguments.join( " " ) );
20742080
process->start( modulePath, arguments );

0 commit comments

Comments
 (0)
Please sign in to comment.