handle error processing file

This commit is contained in:
Antonio J. Delgado 2023-12-23 10:28:10 +02:00
parent 5092a2f6d0
commit 98945baa3b
3 changed files with 11 additions and 7 deletions

View file

@ -88,7 +88,10 @@ class image_classifier:
entries.append(entry)
self._log.info(f"Processing {len(entries)} files...")
for entry in entries:
self.process_file(entry.path)
try:
self.process_file(entry.path)
except Exception as error:
self._log.error(f"Error processing file '{entry.path}'. {error}")
def count(self, iterable):
''' Return the length of an iterable that can't be count with len()'''
@ -236,12 +239,13 @@ folder, '{person_path}'...")
f"Error copying. File not found. {error}"
)
if not self.no_move:
if os.path.exists(os.path.join(new_path, filename)):
full_path = os.path.join(new_path, filename)
if os.path.exists(full_path):
self._log.debug(
f"Destination '{new_path}/{filename}' exists, \
f"Destination '{full_path}' exists, \
removing it..."
)
os.remove(os.path.join(new_path, filename))
os.remove(full_path)
self._log.info(f"Moving file '{file}' to '{new_path}'...")
try:
shutil.move(file, new_path)

View file

@ -1,8 +1,8 @@
[metadata]
name = image_classifier
version = 0.0.19
version = 0.0.20
[options]
packages = image_classifier
install_requires =
importlib; python_version == "3.6"
importlib; python_version == "3.10"

View file

@ -9,7 +9,7 @@ if os.access(requirements_file, os.R_OK):
setuptools.setup(
scripts=['image_classifier/image_classifier.py'],
author="Antonio J. Delgado",
version='0.0.19',
version='0.0.20',
name='image_classifier',
author_email="antoniodelgado@susurrando.com",
url="",