68d7dd98 by 周伟奇

add catch error

1 parent c1ca6fa5
...@@ -379,16 +379,20 @@ class Command(BaseCommand, LoggerMixin): ...@@ -379,16 +379,20 @@ class Command(BaseCommand, LoggerMixin):
379 else: 379 else:
380 wb = Workbook() 380 wb = Workbook()
381 for result in result_list: 381 for result in result_list:
382 sheet_name, head_fields = self.sheet_content[result[self.CLASSIFY_KEY]] 382 try:
383 row = [] 383 sheet_name, head_fields = self.sheet_content[result[self.CLASSIFY_KEY]]
384 for field in head_fields: 384 row = []
385 row.append(result[self.RESULT_KEY].get(field)) 385 for field in head_fields:
386 if sheet_name in wb.sheetnames: 386 row.append(result[self.RESULT_KEY].get(field))
387 ws = wb.get_sheet_by_name(sheet_name) 387 if sheet_name in wb.sheetnames:
388 else: 388 ws = wb.get_sheet_by_name(sheet_name)
389 ws = wb.create_sheet(sheet_name) 389 else:
390 ws.append(head_fields) 390 ws = wb.create_sheet(sheet_name)
391 ws.append(row) 391 ws.append(head_fields)
392 ws.append(row)
393 except Exception as e:
394 self.folder_log.info('{0} [daily wb failed] [result={1}] [error={2}]'.format(
395 self.log_base, result, traceback.format_exc()))
392 wb.save(wb_path) 396 wb.save(wb_path)
393 397
394 def folder_process(self, input_dir, classify, result_queue): 398 def folder_process(self, input_dir, classify, result_queue):
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!