20
20
from builtins import str
21
21
from builtins import object
22
22
23
-
24
23
__author__ = 'Victor Olaya'
25
24
__date__ = 'August 2012'
26
25
__copyright__ = '(C) 2012, Victor Olaya'
63
62
64
63
65
64
class Processing (object ):
66
-
67
65
BASIC_PROVIDERS = []
68
66
69
67
@staticmethod
@@ -121,7 +119,6 @@ def removeScripts(folder):
121
119
provider .externalAlgs .remove (alg )
122
120
provider .refreshAlgorithms ()
123
121
124
-
125
122
@staticmethod
126
123
def runAlgorithm (algOrName , onFinish , * args , ** kwargs ):
127
124
if isinstance (algOrName , GeoAlgorithm ):
@@ -131,7 +128,8 @@ def runAlgorithm(algOrName, onFinish, *args, **kwargs):
131
128
if alg is None :
132
129
# fix_print_with_import
133
130
print ('Error: Algorithm not found\n ' )
134
- QgsMessageLog .logMessage (Processing .tr ('Error: Algorithm {0} not found\n ' ).format (algOrName ), Processing .tr ("Processing" ))
131
+ QgsMessageLog .logMessage (Processing .tr ('Error: Algorithm {0} not found\n ' ).format (algOrName ),
132
+ Processing .tr ("Processing" ))
135
133
return
136
134
alg = alg .getCopy ()
137
135
@@ -149,7 +147,9 @@ def runAlgorithm(algOrName, onFinish, *args, **kwargs):
149
147
continue
150
148
# fix_print_with_import
151
149
print ('Error: Wrong parameter value %s for parameter %s.' % (value , name ))
152
- QgsMessageLog .logMessage (Processing .tr ('Error: Wrong parameter value {0} for parameter {1}.' ).format (value , name ), Processing .tr ("Processing" ))
150
+ QgsMessageLog .logMessage (
151
+ Processing .tr ('Error: Wrong parameter value {0} for parameter {1}.' ).format (value , name ),
152
+ Processing .tr ("Processing" ))
153
153
ProcessingLog .addToLog (
154
154
ProcessingLog .LOG_ERROR ,
155
155
Processing .tr ('Error in {0}. Wrong parameter value {1} for parameter {2}.' ).format (
@@ -163,7 +163,9 @@ def runAlgorithm(algOrName, onFinish, *args, **kwargs):
163
163
if not param .setDefaultValue ():
164
164
# fix_print_with_import
165
165
print ('Error: Missing parameter value for parameter %s.' % param .name )
166
- QgsMessageLog .logMessage (Processing .tr ('Error: Missing parameter value for parameter {0}.' ).format (param .name ), Processing .tr ("Processing" ))
166
+ QgsMessageLog .logMessage (
167
+ Processing .tr ('Error: Missing parameter value for parameter {0}.' ).format (param .name ),
168
+ Processing .tr ("Processing" ))
167
169
ProcessingLog .addToLog (
168
170
ProcessingLog .LOG_ERROR ,
169
171
Processing .tr ('Error in {0}. Missing parameter value for parameter {1}.' ).format (
@@ -174,7 +176,8 @@ def runAlgorithm(algOrName, onFinish, *args, **kwargs):
174
176
if len (args ) != alg .getVisibleParametersCount () + alg .getVisibleOutputsCount ():
175
177
# fix_print_with_import
176
178
print ('Error: Wrong number of parameters' )
177
- QgsMessageLog .logMessage (Processing .tr ('Error: Wrong number of parameters' ), Processing .tr ("Processing" ))
179
+ QgsMessageLog .logMessage (Processing .tr ('Error: Wrong number of parameters' ),
180
+ Processing .tr ("Processing" ))
178
181
processing .algorithmHelp (algOrName )
179
182
return
180
183
i = 0
@@ -183,7 +186,8 @@ def runAlgorithm(algOrName, onFinish, *args, **kwargs):
183
186
if not param .setValue (args [i ]):
184
187
# fix_print_with_import
185
188
print ('Error: Wrong parameter value: ' + str (args [i ]))
186
- QgsMessageLog .logMessage (Processing .tr ('Error: Wrong parameter value: ' ) + str (args [i ]), Processing .tr ("Processing" ))
189
+ QgsMessageLog .logMessage (Processing .tr ('Error: Wrong parameter value: ' ) + str (args [i ]),
190
+ Processing .tr ("Processing" ))
187
191
return
188
192
i = i + 1
189
193
@@ -192,21 +196,25 @@ def runAlgorithm(algOrName, onFinish, *args, **kwargs):
192
196
if not output .setValue (args [i ]):
193
197
# fix_print_with_import
194
198
print ('Error: Wrong output value: ' + str (args [i ]))
195
- QgsMessageLog .logMessage (Processing .tr ('Error: Wrong output value: ' ) + str (args [i ]), Processing .tr ("Processing" ))
199
+ QgsMessageLog .logMessage (Processing .tr ('Error: Wrong output value: ' ) + str (args [i ]),
200
+ Processing .tr ("Processing" ))
196
201
return
197
202
i = i + 1
198
203
199
204
msg = alg ._checkParameterValuesBeforeExecuting ()
200
205
if msg :
201
206
# fix_print_with_import
202
207
print ('Unable to execute algorithm\n ' + str (msg ))
203
- QgsMessageLog .logMessage (Processing .tr ('Unable to execute algorithm\n {0}' ).format (msg ), Processing .tr ("Processing" ))
208
+ QgsMessageLog .logMessage (Processing .tr ('Unable to execute algorithm\n {0}' ).format (msg ),
209
+ Processing .tr ("Processing" ))
204
210
return
205
211
206
212
if not alg .checkInputCRS ():
207
213
print ('Warning: Not all input layers use the same CRS.\n ' +
208
214
'This can cause unexpected results.' )
209
- QgsMessageLog .logMessage (Processing .tr ('Warning: Not all input layers use the same CRS.\n This can cause unexpected results.' ), Processing .tr ("Processing" ))
215
+ QgsMessageLog .logMessage (
216
+ Processing .tr ('Warning: Not all input layers use the same CRS.\n This can cause unexpected results.' ),
217
+ Processing .tr ("Processing" ))
210
218
211
219
# Don't set the wait cursor twice, because then when you
212
220
# restore it, it will still be a wait cursor.
@@ -231,7 +239,8 @@ def runAlgorithm(algOrName, onFinish, *args, **kwargs):
231
239
if onFinish is not None :
232
240
onFinish (alg , feedback )
233
241
else :
234
- QgsMessageLog .logMessage (Processing .tr ("There were errors executing the algorithm." ), Processing .tr ("Processing" ))
242
+ QgsMessageLog .logMessage (Processing .tr ("There were errors executing the algorithm." ),
243
+ Processing .tr ("Processing" ))
235
244
236
245
if overrideCursor :
237
246
QApplication .restoreOverrideCursor ()
0 commit comments