Skip to content

Commit 6ea74d6

Browse files
qgep-ninjam-kuhn
authored andcommitted
Workaround a instable system call
1 parent fa90a7b commit 6ea74d6

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

python/plugins/processing/algs/gdal/GdalUtils.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,23 @@ class GdalUtils:
4545

4646
@staticmethod
4747
def runGdal(commands, progress):
48-
envval = unicode(os.getenv('PATH'))
48+
envval = os.getenv('PATH')
4949
# We need to give some extra hints to get things picked up on OS X
50-
if platform.system() == 'Darwin':
51-
if os.path.isfile(os.path.join(QgsApplication.prefixPath(), "bin", "gdalinfo")):
52-
# Looks like there's a bundled gdal. Let's use it.
53-
os.environ['PATH'] = "%s%s%s" % (os.path.join(QgsApplication.prefixPath(), "bin"), os.pathsep, envval)
54-
os.environ['DYLD_LIBRARY_PATH'] = os.path.join(QgsApplication.prefixPath(), "lib")
55-
else:
56-
# Nothing internal. Let's see if we can find it elsewhere.
57-
settings = QSettings()
58-
path = unicode(settings.value('/GdalTools/gdalPath', ''))
59-
envval += '%s%s' % (os.pathsep, path)
60-
os.putenv('PATH', envval)
50+
isDarwin = False
51+
try:
52+
isDarwin = platform.system() == 'Darwin'
53+
except IOError: # https://travis-ci.org/m-kuhn/QGIS#L1493-L1526
54+
pass
55+
if isDarwin and os.path.isfile(os.path.join(QgsApplication.prefixPath(), "bin", "gdalinfo")):
56+
# Looks like there's a bundled gdal. Let's use it.
57+
os.environ['PATH'] = "{}{}{}".format(os.path.join(QgsApplication.prefixPath(), "bin"), os.pathsep, envval)
58+
os.environ['DYLD_LIBRARY_PATH'] = os.path.join(QgsApplication.prefixPath(), "lib")
6159
else:
6260
# Other platforms should use default gdal finder codepath
6361
settings = QSettings()
64-
path = unicode(settings.value('/GdalTools/gdalPath', ''))
62+
path = settings.value('/GdalTools/gdalPath', '')
6563
if not path.lower() in envval.lower().split(os.pathsep):
66-
envval += '%s%s' % (os.pathsep, path)
64+
envval += '{}{}'.format(os.pathsep, path)
6765
os.putenv('PATH', envval)
6866

6967
loglines = []

0 commit comments

Comments
 (0)