@@ -109,7 +109,7 @@ def progress_rate(self):
109
109
proc = Process (self .cmd , self .cwd )
110
110
proc .run ()
111
111
with DownloadLogFile () as f :
112
- for line in self . proc .read_lines (timeout = 60 ):
112
+ for line in proc .read_lines (timeout = 60 ):
113
113
f .write (line )
114
114
logger .info (line )
115
115
rv = self .parse (line )
@@ -125,6 +125,8 @@ class _AsrExecutor(BaseExecutor):
125
125
def __init__ (self , cmd , cwd , ** extra ):
126
126
self .json_string = ""
127
127
self .flag = False
128
+ self .progress = 0
129
+ self .log_string = ""
128
130
super ().__init__ (cmd , cwd , ** extra )
129
131
130
132
def parse (self , line ):
@@ -143,20 +145,29 @@ def parse(self, line):
143
145
self .json_string = ""
144
146
self .flag = False
145
147
if rv and rv ['status' ] != 'OFFLINE' :
146
- return rv ['progress' ]
147
-
148
+ self .progress = rv ['progress' ]
149
+ return self .log_string , self .progress
150
+ else :
151
+ self .log_string = line
152
+ return self .log_string , self .progress
148
153
149
154
class _200AExecutor (BaseExecutor ):
150
155
156
+ def __init__ (self , cmd , cwd , ** extra ):
157
+ self .progress = 0
158
+ super ().__init__ (cmd , cwd , ** extra )
159
+
151
160
def parse (self , line ):
152
161
if "Successfully to prepare temp folder file for wtptp download" in line :
153
162
return "RESET"
154
-
155
- if "Download percentage" in line :
156
- return int (line .strip ().split (' ' )[- 1 ])
157
-
158
- if "flash percentage" in line :
159
- return int (line .strip ().split (' ' )[- 1 ])
163
+ elif "Download percentage" in line :
164
+ self .progress = int (line .strip ().split (' ' )[- 1 ])
165
+ return line , self .progress
166
+ elif "flash percentage" in line :
167
+ self .progress = int (line .strip ().split (' ' )[- 1 ])
168
+ return line , self .progress
169
+ else :
170
+ return line , self .progress
160
171
161
172
162
173
class _BG95Executor (BaseExecutor ):
@@ -169,24 +180,30 @@ def parse(self, line):
169
180
170
181
if '[1]DL-' in line :
171
182
self .progress += 2
172
- return self .progress
173
-
174
- if '[1]Total upgrade time is' in line :
175
- return 100
176
-
177
- if '[1]FW upgrade fail' in line :
183
+ return line , self .progress
184
+ elif '[1]FW upgrade success.' in line :
185
+ return line , 100
186
+ elif '[1]FW upgrade fail' in line :
178
187
raise Exception ('BG95 FW Download Failed.' )
188
+ else :
189
+ return line , self .progress
179
190
180
191
181
192
class _NBExecutor (BaseExecutor ):
182
193
194
+ def __init__ (self , cmd , cwd , ** extra ):
195
+ self .progress = 0
196
+ super ().__init__ (cmd , cwd , ** extra )
197
+
183
198
def parse (self , line ):
184
199
if '[1]FW upgrade fail.' in line :
185
200
raise Exception ('NB FW Download Failed.' )
186
201
187
202
if "[1]Upgrade:" in line :
188
- progress = int (line .replace ("[1]Upgrade:" , '' ).strip ()[:- 1 ])
189
- return progress
203
+ self .progress = int (line .replace ("[1]Upgrade:" , '' ).strip ()[:- 1 ])
204
+ return line , self .progress
205
+ else :
206
+ return line , self .progress
190
207
191
208
192
209
class _UnisocExecutor (BaseExecutor ):
@@ -199,10 +216,10 @@ def parse(self, line):
199
216
200
217
if "Downloading..." in line :
201
218
self .progress += 1
202
- return self .progress * 10
219
+ return line [: 50 ], self .progress * 10
203
220
204
221
if "DownLoad Passed" in line :
205
- return 100
222
+ return line [: 50 ], 100
206
223
207
224
if "[ERROR] DownLoad Failed" in line :
208
225
raise Exception ('Unisoc FW Download Failed.' )
@@ -214,15 +231,15 @@ def parse(self, line):
214
231
try :
215
232
data = json .loads (line )
216
233
except Exception as e :
217
- return 1
234
+ return line , 1
218
235
219
236
if data ['Status' ] == 'Programming' :
220
- return data ['Progress' ]
237
+ return line , data ['Progress' ]
221
238
else :
222
239
if data ['Status' ] == 'Ready' :
223
- return 5
240
+ return line , 5
224
241
elif data ['Status' ] == 'Finished' and data ['Message' ] == 'Success' :
225
- return 100
242
+ return line , 100
226
243
else :
227
244
raise Exception ('360W Download Failed!' )
228
245
@@ -245,7 +262,7 @@ def progress_rate(self):
245
262
f .write (line )
246
263
logger .info (line )
247
264
self .parse (line )
248
- yield self .progress
265
+ yield line , self .progress
249
266
250
267
# pkg2img
251
268
logger .info ("---------- pkg2img ----------" )
@@ -257,7 +274,7 @@ def progress_rate(self):
257
274
f .write (line )
258
275
logger .info (line )
259
276
self .parse (line )
260
- yield self .progress
277
+ yield line , self .progress
261
278
262
279
# 烧录固件
263
280
logger .info ("---------- Burn firmware ----------" )
@@ -269,7 +286,7 @@ def progress_rate(self):
269
286
f .write (line )
270
287
logger .info (line )
271
288
self .parse (line )
272
- yield self .progress
289
+ yield line , self .progress
273
290
274
291
# 下载 ap_application.bin文件
275
292
logger .info ("---------- Download ap_application.bin flasherase ----------" )
@@ -282,7 +299,7 @@ def progress_rate(self):
282
299
f .write (line )
283
300
logger .info (line )
284
301
self .parse (line )
285
- yield self .progress
302
+ yield line , self .progress
286
303
logger .info ("---------- Download ap_application.bin burnone ----------" )
287
304
cmd5 = self .cmd [:1 ] + ["--skipconnect" , "1" ] + self .cmd [1 :] + ["burnone" , "flexfile2" ]
288
305
logger .info ('cmd5: {}' .format (cmd5 ))
@@ -292,7 +309,7 @@ def progress_rate(self):
292
309
f .write (line )
293
310
logger .info (line )
294
311
self .parse (line )
295
- yield self .progress
312
+ yield line , self .progress
296
313
297
314
# 下载 ap_updater.bin文件
298
315
logger .info ("---------- Download ap_updater.bin flasherase ----------" )
@@ -305,7 +322,7 @@ def progress_rate(self):
305
322
f .write (line )
306
323
logger .info (line )
307
324
self .parse (line )
308
- yield self .progress
325
+ yield line , self .progress
309
326
logger .info ("---------- Download ap_updater.bin burnone ----------" )
310
327
cmd7 = self .cmd [:1 ] + ["--skipconnect" , "1" ] + self .cmd [1 :] + ["burnone" , "flexfile3" ]
311
328
logger .info ('cmd7: {}' .format (cmd7 ))
@@ -315,7 +332,7 @@ def progress_rate(self):
315
332
f .write (line )
316
333
logger .info (line )
317
334
self .parse (line )
318
- yield self .progress
335
+ yield line , self .progress
319
336
320
337
# 下载 customer_fs.bin文件
321
338
logger .info ("---------- Download customer_fs.bin flasherase ----------" )
@@ -328,7 +345,7 @@ def progress_rate(self):
328
345
f .write (line )
329
346
logger .info (line )
330
347
self .parse (line )
331
- yield self .progress
348
+ yield line , self .progress
332
349
logger .info ("---------- Download customer_fs.bin burnone ----------" )
333
350
cmd9 = self .cmd [:1 ] + ["--skipconnect" , "1" ] + self .cmd [1 :] + ["burnone" , "flexfile4" ]
334
351
logger .info ('cmd9: {}' .format (cmd9 ))
@@ -338,7 +355,7 @@ def progress_rate(self):
338
355
f .write (line )
339
356
logger .info (line )
340
357
self .parse (line )
341
- yield self .progress
358
+ yield line , self .progress
342
359
343
360
if self .extra ['File_Count' ] == 4 :
344
361
# 下载 customer_backup_fs.bin 文件
@@ -352,7 +369,7 @@ def progress_rate(self):
352
369
f .write (line )
353
370
logger .info (line )
354
371
self .parse (line )
355
- yield self .progress
372
+ yield line , self .progress
356
373
logger .info ("---------- Download customer_backup_fs.bin burnone ----------" )
357
374
cmd11 = self .cmd [:1 ] + ["--skipconnect" , "1" ] + self .cmd [1 :] + ["burnone" , "flexfile5" ]
358
375
logger .info ('cmd11: {}' .format (cmd11 ))
@@ -362,7 +379,7 @@ def progress_rate(self):
362
379
f .write (line )
363
380
logger .info (line )
364
381
self .parse (line )
365
- yield self .progress
382
+ yield line , self .progress
366
383
367
384
# 重启模块
368
385
logger .info ("---------- sysreset ----------" )
@@ -374,7 +391,7 @@ def progress_rate(self):
374
391
f .write (line )
375
392
logger .info (line )
376
393
self .parse (line )
377
- yield self .progress
394
+ yield line , self .progress
378
395
yield 100
379
396
380
397
def parse (self , line ):
0 commit comments