@@ -109,7 +109,7 @@ def progress_rate(self):
109109 proc = Process (self .cmd , self .cwd )
110110 proc .run ()
111111 with DownloadLogFile () as f :
112- for line in self . proc .read_lines (timeout = 60 ):
112+ for line in proc .read_lines (timeout = 60 ):
113113 f .write (line )
114114 logger .info (line )
115115 rv = self .parse (line )
@@ -125,6 +125,8 @@ class _AsrExecutor(BaseExecutor):
125125 def __init__ (self , cmd , cwd , ** extra ):
126126 self .json_string = ""
127127 self .flag = False
128+ self .progress = 0
129+ self .log_string = ""
128130 super ().__init__ (cmd , cwd , ** extra )
129131
130132 def parse (self , line ):
@@ -143,20 +145,29 @@ def parse(self, line):
143145 self .json_string = ""
144146 self .flag = False
145147 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
148153
149154class _200AExecutor (BaseExecutor ):
150155
156+ def __init__ (self , cmd , cwd , ** extra ):
157+ self .progress = 0
158+ super ().__init__ (cmd , cwd , ** extra )
159+
151160 def parse (self , line ):
152161 if "Successfully to prepare temp folder file for wtptp download" in line :
153162 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
160171
161172
162173class _BG95Executor (BaseExecutor ):
@@ -169,24 +180,30 @@ def parse(self, line):
169180
170181 if '[1]DL-' in line :
171182 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 :
178187 raise Exception ('BG95 FW Download Failed.' )
188+ else :
189+ return line , self .progress
179190
180191
181192class _NBExecutor (BaseExecutor ):
182193
194+ def __init__ (self , cmd , cwd , ** extra ):
195+ self .progress = 0
196+ super ().__init__ (cmd , cwd , ** extra )
197+
183198 def parse (self , line ):
184199 if '[1]FW upgrade fail.' in line :
185200 raise Exception ('NB FW Download Failed.' )
186201
187202 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
190207
191208
192209class _UnisocExecutor (BaseExecutor ):
@@ -199,10 +216,10 @@ def parse(self, line):
199216
200217 if "Downloading..." in line :
201218 self .progress += 1
202- return self .progress * 10
219+ return line [: 50 ], self .progress * 10
203220
204221 if "DownLoad Passed" in line :
205- return 100
222+ return line [: 50 ], 100
206223
207224 if "[ERROR] DownLoad Failed" in line :
208225 raise Exception ('Unisoc FW Download Failed.' )
@@ -214,15 +231,15 @@ def parse(self, line):
214231 try :
215232 data = json .loads (line )
216233 except Exception as e :
217- return 1
234+ return line , 1
218235
219236 if data ['Status' ] == 'Programming' :
220- return data ['Progress' ]
237+ return line , data ['Progress' ]
221238 else :
222239 if data ['Status' ] == 'Ready' :
223- return 5
240+ return line , 5
224241 elif data ['Status' ] == 'Finished' and data ['Message' ] == 'Success' :
225- return 100
242+ return line , 100
226243 else :
227244 raise Exception ('360W Download Failed!' )
228245
@@ -245,7 +262,7 @@ def progress_rate(self):
245262 f .write (line )
246263 logger .info (line )
247264 self .parse (line )
248- yield self .progress
265+ yield line , self .progress
249266
250267 # pkg2img
251268 logger .info ("---------- pkg2img ----------" )
@@ -257,7 +274,7 @@ def progress_rate(self):
257274 f .write (line )
258275 logger .info (line )
259276 self .parse (line )
260- yield self .progress
277+ yield line , self .progress
261278
262279 # 烧录固件
263280 logger .info ("---------- Burn firmware ----------" )
@@ -269,7 +286,7 @@ def progress_rate(self):
269286 f .write (line )
270287 logger .info (line )
271288 self .parse (line )
272- yield self .progress
289+ yield line , self .progress
273290
274291 # 下载 ap_application.bin文件
275292 logger .info ("---------- Download ap_application.bin flasherase ----------" )
@@ -282,7 +299,7 @@ def progress_rate(self):
282299 f .write (line )
283300 logger .info (line )
284301 self .parse (line )
285- yield self .progress
302+ yield line , self .progress
286303 logger .info ("---------- Download ap_application.bin burnone ----------" )
287304 cmd5 = self .cmd [:1 ] + ["--skipconnect" , "1" ] + self .cmd [1 :] + ["burnone" , "flexfile2" ]
288305 logger .info ('cmd5: {}' .format (cmd5 ))
@@ -292,7 +309,7 @@ def progress_rate(self):
292309 f .write (line )
293310 logger .info (line )
294311 self .parse (line )
295- yield self .progress
312+ yield line , self .progress
296313
297314 # 下载 ap_updater.bin文件
298315 logger .info ("---------- Download ap_updater.bin flasherase ----------" )
@@ -305,7 +322,7 @@ def progress_rate(self):
305322 f .write (line )
306323 logger .info (line )
307324 self .parse (line )
308- yield self .progress
325+ yield line , self .progress
309326 logger .info ("---------- Download ap_updater.bin burnone ----------" )
310327 cmd7 = self .cmd [:1 ] + ["--skipconnect" , "1" ] + self .cmd [1 :] + ["burnone" , "flexfile3" ]
311328 logger .info ('cmd7: {}' .format (cmd7 ))
@@ -315,7 +332,7 @@ def progress_rate(self):
315332 f .write (line )
316333 logger .info (line )
317334 self .parse (line )
318- yield self .progress
335+ yield line , self .progress
319336
320337 # 下载 customer_fs.bin文件
321338 logger .info ("---------- Download customer_fs.bin flasherase ----------" )
@@ -328,7 +345,7 @@ def progress_rate(self):
328345 f .write (line )
329346 logger .info (line )
330347 self .parse (line )
331- yield self .progress
348+ yield line , self .progress
332349 logger .info ("---------- Download customer_fs.bin burnone ----------" )
333350 cmd9 = self .cmd [:1 ] + ["--skipconnect" , "1" ] + self .cmd [1 :] + ["burnone" , "flexfile4" ]
334351 logger .info ('cmd9: {}' .format (cmd9 ))
@@ -338,7 +355,7 @@ def progress_rate(self):
338355 f .write (line )
339356 logger .info (line )
340357 self .parse (line )
341- yield self .progress
358+ yield line , self .progress
342359
343360 if self .extra ['File_Count' ] == 4 :
344361 # 下载 customer_backup_fs.bin 文件
@@ -352,7 +369,7 @@ def progress_rate(self):
352369 f .write (line )
353370 logger .info (line )
354371 self .parse (line )
355- yield self .progress
372+ yield line , self .progress
356373 logger .info ("---------- Download customer_backup_fs.bin burnone ----------" )
357374 cmd11 = self .cmd [:1 ] + ["--skipconnect" , "1" ] + self .cmd [1 :] + ["burnone" , "flexfile5" ]
358375 logger .info ('cmd11: {}' .format (cmd11 ))
@@ -362,7 +379,7 @@ def progress_rate(self):
362379 f .write (line )
363380 logger .info (line )
364381 self .parse (line )
365- yield self .progress
382+ yield line , self .progress
366383
367384 # 重启模块
368385 logger .info ("---------- sysreset ----------" )
@@ -374,7 +391,7 @@ def progress_rate(self):
374391 f .write (line )
375392 logger .info (line )
376393 self .parse (line )
377- yield self .progress
394+ yield line , self .progress
378395 yield 100
379396
380397 def parse (self , line ):
0 commit comments