@@ -106,16 +106,21 @@ def getSagaInstalledVersion(runSaga=False):
106
106
global _installedVersion
107
107
global _installedVersionFound
108
108
109
- if not _installedVersionFound or runSaga :
110
- if isWindows ():
111
- commands = [os .path .join (sagaPath (), "saga_cmd.exe" ), "-v" ]
112
- elif isMac ():
113
- commands = [os .path .join (sagaPath (), "saga_cmd" ), "-v" ]
114
- else :
115
- # for Linux use just one string instead of separated parameters as the list
116
- # does not work well together with shell=True option
117
- # (python docs advices to use subprocess32 instead of python2.7's subprocess)
118
- commands = ["saga_cmd -v" ]
109
+ maxRetries = 5
110
+ retries = 0
111
+ if _installedVersionFound or not runSaga :
112
+ return _installedVersion
113
+
114
+ if isWindows ():
115
+ commands = [os .path .join (sagaPath (), "saga_cmd.exe" ), "-v" ]
116
+ elif isMac ():
117
+ commands = [os .path .join (sagaPath (), "saga_cmd -v" )]
118
+ else :
119
+ # for Linux use just one string instead of separated parameters as the list
120
+ # does not work well together with shell=True option
121
+ # (python docs advices to use subprocess32 instead of python2.7's subprocess)
122
+ commands = ["saga_cmd -v" ]
123
+ while retries < maxRetries :
119
124
proc = subprocess .Popen (
120
125
commands ,
121
126
shell = True ,
@@ -126,14 +131,19 @@ def getSagaInstalledVersion(runSaga=False):
126
131
).stdout
127
132
try :
128
133
lines = proc .readlines ()
134
+ for line in lines :
135
+ if line .startswith ("SAGA Version:" ):
136
+ _installedVersion = line [len ("SAGA Version:" ):].strip ().split (" " )[0 ]
137
+ _installedVersionFound = True
138
+ return _installedVersion
139
+ except IOError :
140
+ retries += 1
129
141
except :
130
142
return None
131
- for line in lines :
132
- if line .startswith ("SAGA Version:" ):
133
- _installedVersion = line [len ("SAGA Version:" ):].strip ().split (" " )[0 ]
134
- _installedVersionFound = True
143
+
135
144
return _installedVersion
136
145
146
+
137
147
def executeSaga (progress ):
138
148
if isWindows ():
139
149
command = ['cmd.exe' , '/C ' , sagaBatchJobFilename ()]
0 commit comments