fix bug
Showing
2 changed files
with
12 additions
and
2 deletions
| ... | @@ -165,7 +165,12 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -165,7 +165,12 @@ class Command(BaseCommand, LoggerMixin): |
| 165 | def folder_process(self, input_dir, classify): | 165 | def folder_process(self, input_dir, classify): |
| 166 | while not os.path.isdir(input_dir): | 166 | while not os.path.isdir(input_dir): |
| 167 | self.folder_log.info('{0} [input dir is not dir] [input_dir={1}]'.format(self.log_base, input_dir)) | 167 | self.folder_log.info('{0} [input dir is not dir] [input_dir={1}]'.format(self.log_base, input_dir)) |
| 168 | time.sleep(self.sleep_time) | 168 | print(self.switch) |
| 169 | if self.switch: | ||
| 170 | time.sleep(self.sleep_time) | ||
| 171 | continue | ||
| 172 | else: | ||
| 173 | return | ||
| 169 | output_dir = os.path.join(os.path.dirname(input_dir), 'Output') | 174 | output_dir = os.path.join(os.path.dirname(input_dir), 'Output') |
| 170 | img_output_dir = os.path.join(output_dir, 'image') | 175 | img_output_dir = os.path.join(output_dir, 'image') |
| 171 | wb_output_dir = os.path.join(output_dir, 'excel') | 176 | wb_output_dir = os.path.join(output_dir, 'excel') |
| ... | @@ -177,11 +182,16 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -177,11 +182,16 @@ class Command(BaseCommand, LoggerMixin): |
| 177 | os.makedirs(pdf_output_dir, exist_ok=True) | 182 | os.makedirs(pdf_output_dir, exist_ok=True) |
| 178 | os.makedirs(failed_output_dir, exist_ok=True) | 183 | os.makedirs(failed_output_dir, exist_ok=True) |
| 179 | while self.switch: | 184 | while self.switch: |
| 185 | if not os.path.isdir(input_dir): | ||
| 186 | self.folder_log.info('{0} [input dir is not dir] [input_dir={1}]'.format(self.log_base, input_dir)) | ||
| 187 | time.sleep(self.sleep_time) | ||
| 188 | continue | ||
| 180 | # 1. 从input dir获取pdf or image | 189 | # 1. 从input dir获取pdf or image |
| 181 | list_dir = os.listdir(input_dir) | 190 | list_dir = os.listdir(input_dir) |
| 182 | if not list_dir: | 191 | if not list_dir: |
| 183 | self.folder_log.info('{0} [input dir empty] [input_dir={1}]'.format(self.log_base, input_dir)) | 192 | self.folder_log.info('{0} [input dir empty] [input_dir={1}]'.format(self.log_base, input_dir)) |
| 184 | time.sleep(self.sleep_time) | 193 | time.sleep(self.sleep_time) |
| 194 | continue | ||
| 185 | for name in list_dir: | 195 | for name in list_dir: |
| 186 | try: | 196 | try: |
| 187 | path = os.path.join(input_dir, name) | 197 | path = os.path.join(input_dir, name) | ... | ... |
| ... | @@ -294,7 +294,7 @@ class DocView(GenericView, DocHandler): | ... | @@ -294,7 +294,7 @@ class DocView(GenericView, DocHandler): |
| 294 | 294 | ||
| 295 | pdf_file = args.get('pdf_file') | 295 | pdf_file = args.get('pdf_file') |
| 296 | if isinstance(pdf_file.name, str): | 296 | if isinstance(pdf_file.name, str): |
| 297 | if not pdf_file.name.endswith('pdf') or not pdf_file.name.endswith('PDF'): | 297 | if not pdf_file.name.endswith('pdf') and not pdf_file.name.endswith('PDF'): |
| 298 | self.invalid_params(msg='invalid params: not a PDF file') | 298 | self.invalid_params(msg='invalid params: not a PDF file') |
| 299 | 299 | ||
| 300 | business_type = random.choice(consts.BUSINESS_TYPE_LIST) | 300 | business_type = random.choice(consts.BUSINESS_TYPE_LIST) | ... | ... |
-
Please register or sign in to post a comment