Add error handling

This commit is contained in:
Antonio J. Delgado 2021-11-05 08:21:06 +02:00
parent b22f71e3a3
commit 87a30a0dbb

View file

@ -85,8 +85,11 @@ class image_classifier:
self._log.debug(f"People (before): {self.metadata['Xmp.iptcExt.PersonInImage'].raw_value} (type: {type(self.metadata['Xmp.iptcExt.PersonInImage'].raw_value)})")
self.append_people(people)
self._log.debug(f"People (after): {self.metadata['Xmp.iptcExt.PersonInImage'].raw_value} (type: {type(self.metadata['Xmp.iptcExt.PersonInImage'].raw_value)})")
self.metadata.write()
self._log.debug(f"Updated file '{file}'.")
try:
self.metadata.write()
self._log.debug(f"Updated file '{file}'.")
except OSError as error:
self._log.error(f"Error writing metadata to picture file. {error}")
if 'Exif.Photo.DateTimeOriginal' in self.metadata.exif_keys:
original_date = self.metadata['Exif.Photo.DateTimeOriginal'].value
self._log.debug(f"File creation time: {original_date} (type: {type(original_date)})")