Added error_str to ExportResults

This commit is contained in:
Rhet Turnbull
2021-01-05 21:34:46 -08:00
parent ad9dcd9ed7
commit d78097ccc0
2 changed files with 13 additions and 2 deletions

View File

@@ -72,6 +72,7 @@ class ExportResults:
sidecar_xmp_skipped=None,
missing=None,
error=None,
error_str=None,
exiftool_warning=None,
exiftool_error=None,
xattr_written=None,
@@ -92,6 +93,7 @@ class ExportResults:
self.sidecar_xmp_skipped = sidecar_xmp_skipped or []
self.missing = missing or []
self.error = error or []
self.error_str = error_str or []
self.exiftool_warning = exiftool_warning or []
self.exiftool_error = exiftool_error or []
self.xattr_written = xattr_written or []
@@ -138,6 +140,7 @@ class ExportResults:
self.sidecar_xmp_skipped += other.sidecar_xmp_skipped
self.missing += other.missing
self.error += other.error
self.error_str += other.error_str
self.exiftool_warning += other.exiftool_warning
self.exiftool_error += other.exiftool_error
return self
@@ -160,6 +163,7 @@ class ExportResults:
+ f",sidecar_xmp_skipped={self.sidecar_xmp_skipped}"
+ f",missing={self.missing}"
+ f",error={self.error}"
+ f",error_str={self.error_str}"
+ f",exiftool_warning={self.exiftool_warning}"
+ f",exiftool_error={self.exiftool_error}"
+ ")"
@@ -829,6 +833,7 @@ def export2(
photo = [p for p in bursts if p.uuid.startswith(self.uuid)]
photo = photo[0] if photo else None
if not photo:
errors.append(dest)
logging.warning(f"PhotoKitFetchFailed exception exporting photo {self.uuid}: {e}")
if photo:
exported = photo.export(
@@ -1016,6 +1021,7 @@ def export2(
exiftool_warning = []
exiftool_error = []
errors = []
error_strs = []
# TODO: remove duplicative code from below
if exiftool and update and exif_files:
for exported_file in exif_files:
@@ -1139,6 +1145,7 @@ def export2(
sidecar_xmp_written=sidecar_xmp_files_written,
sidecar_xmp_skipped=sidecar_xmp_files_skipped,
error=errors,
error_str=error_strs,
exiftool_error=exiftool_error,
exiftool_warning=exiftool_warning,
)

View File

@@ -19,6 +19,7 @@ EXPORT_RESULT_ATTRIBUTES = [
"sidecar_xmp_skipped",
"missing",
"error",
"error_str",
"exiftool_warning",
"exiftool_error",
]
@@ -41,6 +42,7 @@ def test_exportresults_init():
assert results.sidecar_xmp_skipped == []
assert results.missing == []
assert results.error == []
assert results.error_str == []
assert results.exiftool_warning == []
assert results.exiftool_error == []
@@ -80,12 +82,14 @@ def test_all_files():
""" test ExportResults.all_files() """
results = ExportResults()
for x in EXPORT_RESULT_ATTRIBUTES:
if x == "error_str":
continue
setattr(results, x, [f"{x}1"])
results.exiftool_warning = [("exiftool_warning1", "foo")]
results.exiftool_error = [("exiftool_error1", "foo")]
assert sorted(results.all_files()) == sorted(
[f"{x}1" for x in EXPORT_RESULT_ATTRIBUTES]
[f"{x}1" for x in EXPORT_RESULT_ATTRIBUTES if x != "error_str"]
)
@@ -94,6 +98,6 @@ def test_str():
results = ExportResults()
assert (
str(results)
== "ExportResults(exported=[],new=[],updated=[],skipped=[],exif_updated=[],touched=[],converted_to_jpeg=[],sidecar_json_written=[],sidecar_json_skipped=[],sidecar_exiftool_written=[],sidecar_exiftool_skipped=[],sidecar_xmp_written=[],sidecar_xmp_skipped=[],missing=[],error=[],exiftool_warning=[],exiftool_error=[])"
== "ExportResults(exported=[],new=[],updated=[],skipped=[],exif_updated=[],touched=[],converted_to_jpeg=[],sidecar_json_written=[],sidecar_json_skipped=[],sidecar_exiftool_written=[],sidecar_exiftool_skipped=[],sidecar_xmp_written=[],sidecar_xmp_skipped=[],missing=[],error=[],error_str=[],exiftool_warning=[],exiftool_error=[])"
)