Better GRASS detection on Windows, fixed GRASS engine reference bug

pull/836/head
Piero Toffanin 2020-03-20 14:26:42 -04:00
rodzic de2aafa670
commit b13fe89f8f
1 zmienionych plików z 9 dodań i 3 usunięć

Wyświetl plik

@ -12,11 +12,17 @@ logger = logging.getLogger('app.logger')
class GrassEngine:
def __init__(self):
self.grass_binary = shutil.which('grass7') or \
shutil.which('grass7.bat') or \
shutil.which('grass72') or \
shutil.which('grass72.bat') or \
shutil.which('grass74') or \
shutil.which('grass74.bat') or \
shutil.which('grass76') or \
shutil.which('grass76.bat') or \
shutil.which('grass78') or \
shutil.which('grass80')
shutil.which('grass78.bat') or \
shutil.which('grass80') or \
shutil.which('grass80.bat')
if self.grass_binary is None:
logger.warning("Could not find a GRASS 7 executable. GRASS scripts will not work.")
@ -34,7 +40,7 @@ class GrassContext:
if tmpdir is None:
tmpdir = os.path.basename(tempfile.mkdtemp('_grass_engine', dir=settings.MEDIA_TMP))
self.tmpdir = tmpdir
self.script_opts = script_opts
self.script_opts = script_opts.copy()
self.location = location
self.auto_cleanup = auto_cleanup
@ -95,7 +101,7 @@ class GrassContext:
try:
out = subprocess.check_output(command, cwd=self.get_cwd()).decode('utf-8').strip()
success = True
except subprocess.CalledProcessError:
except:
success = False
err = out
else: