Skip to content

Commit

Permalink
[BACKPORT] find python on OSX (partially fix #3097)
Browse files Browse the repository at this point in the history
don't overwrite PATH env var, but append to it.
  • Loading branch information
brushtyler authored and alexbruy committed Dec 2, 2011
1 parent 505fe5b commit f093f51
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
6 changes: 6 additions & 0 deletions python/plugins/GdalTools/tools/GdalTools_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,3 +760,9 @@ def __cmp__(self, other):

def __str__(self):
return ".".join(self.vers)


# setup the default MacOs path
#if platform.system() == "Darwin" and getGdalPath().isEmpty():
# setGdalPath( u"/Library/Frameworks/GDAL.framework/Versions/%s/Programs" % str(GdalConfig.version())[:3] )

17 changes: 10 additions & 7 deletions python/plugins/GdalTools/tools/dialogBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@ def __init__(self, parent, iface, pluginBase, pluginName, pluginCommand):
self.process = QProcess(self)
gdalPath = Utils.getGdalPath()
if not gdalPath.isEmpty():
sep = ";" if platform.system() == "Windows" else ":"
env = self.process.environment()
if env.isEmpty():
#env << "PATH=" + gdalPath
os.putenv( "PATH", str( gdalPath ) )
# process.enviroment() is probably not supported (MacOS?),
# use os.putenv() instead
path = os.getenv("PATH")
if path != "":
path += sep
path += gdalPath
os.putenv( "PATH", path )
else:
if platform.system() == "Windows":
env.replaceInStrings( QRegExp( "^PATH=(.*)", Qt.CaseInsensitive ), "PATH=\\1;" + gdalPath )
else:
env.replaceInStrings( QRegExp( "^PATH=(.*)", Qt.CaseInsensitive ), "PATH=\\1:" + gdalPath )
self.process.setEnvironment( env )
env.replaceInStrings( QRegExp( "^PATH=(.*)", Qt.CaseInsensitive ), "PATH=\\1%s%s" % (sep, gdalPath) )
self.process.setEnvironment( env )
self.connect(self.process, SIGNAL("error(QProcess::ProcessError)"), self.processError)
self.connect(self.process, SIGNAL("finished(int, QProcess::ExitStatus)"), self.processFinished)

Expand Down

0 comments on commit f093f51

Please sign in to comment.