@@ -91,25 +91,30 @@ def installedVersion(run=False):
91
91
92
92
if Grass7Utils .grassPath () is None :
93
93
return None
94
- commands = ["grass70 -v" ]
95
- with subprocess .Popen (
96
- commands ,
97
- shell = True ,
98
- stdout = subprocess .PIPE ,
99
- stdin = subprocess .DEVNULL ,
100
- stderr = subprocess .STDOUT ,
101
- universal_newlines = True ,
102
- ) as proc :
103
- try :
104
- lines = proc .stdout .readlines ()
105
- for line in lines :
106
- if "GRASS GIS " in line :
107
- Grass7Utils .version = line .split (" " )[- 1 ].strip ()
108
- break
109
- except :
110
- pass
111
94
112
- return Grass7Utils .version
95
+ for command in ["grass73" , "grass72" , "grass71" , "grass70" , "grass" ]:
96
+ with subprocess .Popen (
97
+ ["{} -v" .format (command )],
98
+ shell = True ,
99
+ stdout = subprocess .PIPE ,
100
+ stdin = subprocess .DEVNULL ,
101
+ stderr = subprocess .STDOUT ,
102
+ universal_newlines = True ,
103
+ ) as proc :
104
+ try :
105
+ lines = proc .stdout .readlines ()
106
+ for line in lines :
107
+ if "GRASS GIS " in line :
108
+ line = line .split (" " )[- 1 ].strip ()
109
+ if line .startswith ("7." ):
110
+ Grass7Utils .version = line
111
+ Grass7Utils .command = command
112
+ return Grass7Utils .version
113
+ except :
114
+ pass
115
+
116
+ return None
117
+
113
118
114
119
@staticmethod
115
120
def grassPath ():
@@ -269,13 +274,13 @@ def prepareGrass7Execution(commands):
269
274
if 'GISBASE' in env :
270
275
del env ['GISBASE' ]
271
276
Grass7Utils .createGrass7BatchJobFileFromGrass7Commands (commands )
272
- os .chmod (Grass7Utils .grassBatchJobFilename (), stat .S_IEXEC
273
- | stat .S_IREAD | stat .S_IWRITE )
277
+ os .chmod (Grass7Utils .grassBatchJobFilename (), stat .S_IEXEC | stat .S_IREAD | stat .S_IWRITE )
274
278
if isMac () and os .path .exists (os .path .join (Grass7Utils .grassPath (), 'grass.sh' )):
275
279
command = os .path .join (Grass7Utils .grassPath (), 'grass.sh' ) + ' ' \
276
280
+ os .path .join (Grass7Utils .grassMapsetFolder (), 'PERMANENT' )
277
281
else :
278
- command = 'grass70 ' + os .path .join (Grass7Utils .grassMapsetFolder (), 'PERMANENT' )
282
+ print ("Grass {}" .format (Grass7Utils .version ))
283
+ command = Grass7Utils .command + ' ' + os .path .join (Grass7Utils .grassMapsetFolder (), 'PERMANENT' )
279
284
280
285
return command , env
281
286
@@ -449,4 +454,4 @@ def grassHelpPath():
449
454
helpPath = os .path .abspath (path )
450
455
break
451
456
452
- return helpPath if helpPath is not None else 'http://grass.osgeo.org/grass70 /manuals/'
457
+ return helpPath if helpPath is not None else 'http://grass.osgeo.org/{} /manuals/' . format ( Grass7Utils . command )
0 commit comments