fix bug
Showing
2 changed files
with
17 additions
and
16 deletions
... | @@ -7,6 +7,7 @@ import asyncio | ... | @@ -7,6 +7,7 @@ import asyncio |
7 | import aiohttp | 7 | import aiohttp |
8 | import difflib | 8 | import difflib |
9 | import requests | 9 | import requests |
10 | import traceback | ||
10 | from collections import Counter | 11 | from collections import Counter |
11 | from datetime import datetime, date | 12 | from datetime import datetime, date |
12 | from django.utils import timezone | 13 | from django.utils import timezone |
... | @@ -93,7 +94,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -93,7 +94,7 @@ class Command(BaseCommand, LoggerMixin): |
93 | self.edms.download(pdf_path, doc.metadata_version_id) | 94 | self.edms.download(pdf_path, doc.metadata_version_id) |
94 | except Exception as e: | 95 | except Exception as e: |
95 | self.cronjob_log.warn('{0} [edms download failed] [times={1}] [pdf_path={2}] ' | 96 | self.cronjob_log.warn('{0} [edms download failed] [times={1}] [pdf_path={2}] ' |
96 | '[error={3}]'.format(self.log_base, times, pdf_path, e)) | 97 | '[error={3}]'.format(self.log_base, times, pdf_path, traceback.format_exc())) |
97 | edms_exc = str(e) | 98 | edms_exc = str(e) |
98 | else: | 99 | else: |
99 | break | 100 | break |
... | @@ -398,13 +399,13 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -398,13 +399,13 @@ class Command(BaseCommand, LoggerMixin): |
398 | except EDMSException as e: | 399 | except EDMSException as e: |
399 | doc.status = DocStatus.PROCESS_FAILED.value | 400 | doc.status = DocStatus.PROCESS_FAILED.value |
400 | doc.save() | 401 | doc.save() |
401 | self.cronjob_log.error('{0} [process failed (edms download)] [task={1}] [err={2}]'.format( | 402 | self.cronjob_log.error('{0} [process failed (edms download)] [task={1}] [error={2}]'.format( |
402 | self.log_base, task_str, e)) | 403 | self.log_base, task_str, traceback.format_exc())) |
403 | except Exception as e: | 404 | except Exception as e: |
404 | doc.status = DocStatus.PROCESS_FAILED.value | 405 | doc.status = DocStatus.PROCESS_FAILED.value |
405 | doc.save() | 406 | doc.save() |
406 | self.cronjob_log.error('{0} [process failed (pdf to img)] [task={1}] [err={2}]'.format( | 407 | self.cronjob_log.error('{0} [process failed (pdf to img)] [task={1}] [error={2}]'.format( |
407 | self.log_base, task_str, e)) | 408 | self.log_base, task_str, traceback.format_exc())) |
408 | 409 | ||
409 | def img_2_ocr_1(self, img_queue, todo_count_dict, res_dict, finish_queue, lock, url): | 410 | def img_2_ocr_1(self, img_queue, todo_count_dict, res_dict, finish_queue, lock, url): |
410 | while True: | 411 | while True: |
... | @@ -432,7 +433,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -432,7 +433,7 @@ class Command(BaseCommand, LoggerMixin): |
432 | raise OCR1Exception('ocr_1 status code: {0}'.format(ocr_1_response.status_code)) | 433 | raise OCR1Exception('ocr_1 status code: {0}'.format(ocr_1_response.status_code)) |
433 | except Exception as e: | 434 | except Exception as e: |
434 | self.cronjob_log.warn('{0} [ocr_1 failed] [times={1}] [img_path={2}] [error={3}]'.format( | 435 | self.cronjob_log.warn('{0} [ocr_1 failed] [times={1}] [img_path={2}] [error={3}]'.format( |
435 | self.log_base, times, img_path, e)) | 436 | self.log_base, times, img_path, traceback.format_exc())) |
436 | else: | 437 | else: |
437 | ocr_1_res = ocr_1_response.json() | 438 | ocr_1_res = ocr_1_response.json() |
438 | end_time = time.time() | 439 | end_time = time.time() |
... | @@ -525,7 +526,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -525,7 +526,7 @@ class Command(BaseCommand, LoggerMixin): |
525 | except Exception as e: | 526 | except Exception as e: |
526 | self.cronjob_log.warn( | 527 | self.cronjob_log.warn( |
527 | '{0} [ocr_2 failed] [times={1}] [img_path={2}] [error={3}]'.format( | 528 | '{0} [ocr_2 failed] [times={1}] [img_path={2}] [error={3}]'.format( |
528 | self.log_base, times, img_path, e)) | 529 | self.log_base, times, img_path, traceback.format_exc())) |
529 | else: | 530 | else: |
530 | ocr_2_res = json.loads(ocr_2_response.text) | 531 | ocr_2_res = json.loads(ocr_2_response.text) |
531 | end_time = time.time() | 532 | end_time = time.time() |
... | @@ -591,8 +592,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -591,8 +592,8 @@ class Command(BaseCommand, LoggerMixin): |
591 | doc, _ = self.get_doc_object(task_str) | 592 | doc, _ = self.get_doc_object(task_str) |
592 | doc.status = DocStatus.PROCESS_FAILED.value | 593 | doc.status = DocStatus.PROCESS_FAILED.value |
593 | doc.save() | 594 | doc.save() |
594 | self.cronjob_log.error('{0} [process failed (res to wb)] [task={1}] [err={2}]'.format( | 595 | self.cronjob_log.error('{0} [process failed (res to wb)] [task={1}] [error={2}]'.format( |
595 | self.log_base, task_str, e)) | 596 | self.log_base, task_str, traceback.format_exc())) |
596 | else: | 597 | else: |
597 | try: | 598 | try: |
598 | # 5.上传至EDMS | 599 | # 5.上传至EDMS |
... | @@ -602,7 +603,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -602,7 +603,7 @@ class Command(BaseCommand, LoggerMixin): |
602 | except Exception as e: | 603 | except Exception as e: |
603 | self.cronjob_log.warn( | 604 | self.cronjob_log.warn( |
604 | '{0} [edms upload failed] [times={1}] [task={2}] [error={3}]'.format( | 605 | '{0} [edms upload failed] [times={1}] [task={2}] [error={3}]'.format( |
605 | self.log_base, times, task_str, e)) | 606 | self.log_base, times, task_str, traceback.format_exc())) |
606 | edms_exc = str(e) | 607 | edms_exc = str(e) |
607 | else: | 608 | else: |
608 | break | 609 | break |
... | @@ -616,8 +617,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -616,8 +617,8 @@ class Command(BaseCommand, LoggerMixin): |
616 | if hasattr(doc, field): | 617 | if hasattr(doc, field): |
617 | setattr(doc, field, count) | 618 | setattr(doc, field, count) |
618 | doc.save() | 619 | doc.save() |
619 | self.cronjob_log.error('{0} [process failed (edms upload)] [task={1}] [err={2}]'.format( | 620 | self.cronjob_log.error('{0} [process failed (edms upload)] [task={1}] [error={2}]'.format( |
620 | self.log_base, task_str, e)) | 621 | self.log_base, task_str, traceback.format_exc())) |
621 | write_zip_file(img_save_path, os.path.join(doc_data_path, '{0}_img.zip'.format(doc.id))) | 622 | write_zip_file(img_save_path, os.path.join(doc_data_path, '{0}_img.zip'.format(doc.id))) |
622 | 623 | ||
623 | else: | 624 | else: | ... | ... |
... | @@ -161,13 +161,13 @@ class BSWorkbook(Workbook): | ... | @@ -161,13 +161,13 @@ class BSWorkbook(Workbook): |
161 | if max_find_count == 0: | 161 | if max_find_count == 0: |
162 | return round(random.uniform(75, 80), 2) | 162 | return round(random.uniform(75, 80), 2) |
163 | elif max_find_count == 1: | 163 | elif max_find_count == 1: |
164 | return round(random.uniform(80, 85)) | 164 | return round(random.uniform(80, 85), 2) |
165 | elif max_find_count == 2: | 165 | elif max_find_count == 2: |
166 | return round(random.uniform(85, 90)) | 166 | return round(random.uniform(85, 90), 2) |
167 | elif max_find_count == 3: | 167 | elif max_find_count == 3: |
168 | return round(random.uniform(90, 95)) | 168 | return round(random.uniform(90, 95), 2) |
169 | else: | 169 | else: |
170 | return round(random.uniform(95, 100)) | 170 | return round(random.uniform(95, 100), 2) |
171 | 171 | ||
172 | @staticmethod | 172 | @staticmethod |
173 | def month_split(dti, date_list, date_statistics): | 173 | def month_split(dti, date_list, date_statistics): | ... | ... |
-
Please register or sign in to post a comment