b3e0d9bc by 周伟奇

fix bug

1 parent d213eb78
...@@ -188,6 +188,12 @@ class Command(BaseCommand, LoggerMixin): ...@@ -188,6 +188,12 @@ class Command(BaseCommand, LoggerMixin):
188 self.folder_log.error('{0} [wb build error] [path={1}] [error={2}]'.format( 188 self.folder_log.error('{0} [wb build error] [path={1}] [error={2}]'.format(
189 self.log_base, excel_path, traceback.format_exc())) 189 self.log_base, excel_path, traceback.format_exc()))
190 190
191 def basename(self, path):
192 # A basename() variant which first strips the trailing slash, if present.
193 # Thus we always get the last component of the path, even for directories.
194 sep = os.path.sep + (os.path.altsep or '')
195 return os.path.basename(path.rstrip(sep))
196
191 def ocr_process(self, img_path, classify, all_res, seperate_dir): 197 def ocr_process(self, img_path, classify, all_res, seperate_dir):
192 if os.path.exists(img_path): 198 if os.path.exists(img_path):
193 # TODO 图片验证 199 # TODO 图片验证
...@@ -225,7 +231,9 @@ class Command(BaseCommand, LoggerMixin): ...@@ -225,7 +231,9 @@ class Command(BaseCommand, LoggerMixin):
225 if ocr_data.get('classify') == classify: 231 if ocr_data.get('classify') == classify:
226 if seperate_dir is not None: 232 if seperate_dir is not None:
227 os.makedirs(seperate_dir, exist_ok=True) 233 os.makedirs(seperate_dir, exist_ok=True)
228 shutil.move(img_path, seperate_dir) 234 real_dst = os.path.join(seperate_dir, self.basename(img_path))
235 if not os.path.exists(real_dst):
236 shutil.move(img_path, seperate_dir)
229 if classify in consts.LICENSE_CLASSIFY_SET_1: 237 if classify in consts.LICENSE_CLASSIFY_SET_1:
230 self.license1_process(ocr_data, all_res, classify) 238 self.license1_process(ocr_data, all_res, classify)
231 elif classify in consts.LICENSE_CLASSIFY_SET_2: 239 elif classify in consts.LICENSE_CLASSIFY_SET_2:
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!