Handle file not found error during file processing
This commit is contained in:
parent
c910cf7877
commit
87f7cc763f
1 changed files with 3 additions and 0 deletions
|
|
@ -244,6 +244,8 @@ class Command(BaseCommand):
|
||||||
else:
|
else:
|
||||||
self.stdout.write(f"{file_path!s} already exists in {processed_path!s}, removing original file.")
|
self.stdout.write(f"{file_path!s} already exists in {processed_path!s}, removing original file.")
|
||||||
file_path.unlink()
|
file_path.unlink()
|
||||||
|
except FileNotFoundError:
|
||||||
|
self.stdout.write(f"{file_path!s} not found, skipping.")
|
||||||
except (PermissionError, OSError, shutil.Error) as e:
|
except (PermissionError, OSError, shutil.Error) as e:
|
||||||
self.stdout.write(self.style.ERROR(f"Error moving {file_path!s} to {processed_path!s}: {e}"))
|
self.stdout.write(self.style.ERROR(f"Error moving {file_path!s} to {processed_path!s}: {e}"))
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
@ -547,6 +549,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
# If not found, move the file for manual review
|
# If not found, move the file for manual review
|
||||||
self.stdout.write(self.style.WARNING("No organization found for this campaign, moving file for review."))
|
self.stdout.write(self.style.WARNING("No organization found for this campaign, moving file for review."))
|
||||||
|
|
||||||
todo_dir: Path = Path("check_these_please")
|
todo_dir: Path = Path("check_these_please")
|
||||||
todo_dir.mkdir(parents=True, exist_ok=True)
|
todo_dir.mkdir(parents=True, exist_ok=True)
|
||||||
self.move_file(
|
self.move_file(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue