mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-15 00:02:52 -04:00
[processing] find grass >=7.0
This commit is contained in:
parent
d8ed8f4355
commit
099e7a77f2
@ -91,9 +91,10 @@ class Grass7Utils(object):
|
|||||||
|
|
||||||
if Grass7Utils.grassPath() is None:
|
if Grass7Utils.grassPath() is None:
|
||||||
return None
|
return None
|
||||||
commands = ["grass70 -v"]
|
|
||||||
|
for command in ["grass73", "grass72", "grass71", "grass70", "grass"]:
|
||||||
with subprocess.Popen(
|
with subprocess.Popen(
|
||||||
commands,
|
["{} -v".format(command)],
|
||||||
shell=True,
|
shell=True,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stdin=subprocess.DEVNULL,
|
stdin=subprocess.DEVNULL,
|
||||||
@ -104,12 +105,16 @@ class Grass7Utils(object):
|
|||||||
lines = proc.stdout.readlines()
|
lines = proc.stdout.readlines()
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if "GRASS GIS " in line:
|
if "GRASS GIS " in line:
|
||||||
Grass7Utils.version = line.split(" ")[-1].strip()
|
line = line.split(" ")[-1].strip()
|
||||||
break
|
if line.startswith("7."):
|
||||||
|
Grass7Utils.version = line
|
||||||
|
Grass7Utils.command = command
|
||||||
|
return Grass7Utils.version
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return Grass7Utils.version
|
return None
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def grassPath():
|
def grassPath():
|
||||||
@ -269,13 +274,13 @@ class Grass7Utils(object):
|
|||||||
if 'GISBASE' in env:
|
if 'GISBASE' in env:
|
||||||
del env['GISBASE']
|
del env['GISBASE']
|
||||||
Grass7Utils.createGrass7BatchJobFileFromGrass7Commands(commands)
|
Grass7Utils.createGrass7BatchJobFileFromGrass7Commands(commands)
|
||||||
os.chmod(Grass7Utils.grassBatchJobFilename(), stat.S_IEXEC
|
os.chmod(Grass7Utils.grassBatchJobFilename(), stat.S_IEXEC | stat.S_IREAD | stat.S_IWRITE)
|
||||||
| stat.S_IREAD | stat.S_IWRITE)
|
|
||||||
if isMac() and os.path.exists(os.path.join(Grass7Utils.grassPath(), 'grass.sh')):
|
if isMac() and os.path.exists(os.path.join(Grass7Utils.grassPath(), 'grass.sh')):
|
||||||
command = os.path.join(Grass7Utils.grassPath(), 'grass.sh') + ' ' \
|
command = os.path.join(Grass7Utils.grassPath(), 'grass.sh') + ' ' \
|
||||||
+ os.path.join(Grass7Utils.grassMapsetFolder(), 'PERMANENT')
|
+ os.path.join(Grass7Utils.grassMapsetFolder(), 'PERMANENT')
|
||||||
else:
|
else:
|
||||||
command = 'grass70 ' + os.path.join(Grass7Utils.grassMapsetFolder(), 'PERMANENT')
|
print("Grass {}".format(Grass7Utils.version))
|
||||||
|
command = Grass7Utils.command + ' ' + os.path.join(Grass7Utils.grassMapsetFolder(), 'PERMANENT')
|
||||||
|
|
||||||
return command, env
|
return command, env
|
||||||
|
|
||||||
@ -449,4 +454,4 @@ class Grass7Utils(object):
|
|||||||
helpPath = os.path.abspath(path)
|
helpPath = os.path.abspath(path)
|
||||||
break
|
break
|
||||||
|
|
||||||
return helpPath if helpPath is not None else 'http://grass.osgeo.org/grass70/manuals/'
|
return helpPath if helpPath is not None else 'http://grass.osgeo.org/{}/manuals/'.format(Grass7Utils.command)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user