Added retry to use_photos_export, issue #351
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
""" version info """
|
""" version info """
|
||||||
|
|
||||||
__version__ = "0.39.18"
|
__version__ = "0.39.19"
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ from ..photokit import (
|
|||||||
)
|
)
|
||||||
from ..utils import dd_to_dms_str, findfiles, noop, get_preferred_uti_extension
|
from ..utils import dd_to_dms_str, findfiles, noop, get_preferred_uti_extension
|
||||||
|
|
||||||
|
# retry if use_photos_export fails the first time (which sometimes it does)
|
||||||
|
MAX_PHOTOSCRIPT_RETRIES = 3
|
||||||
|
|
||||||
|
|
||||||
class ExportError(Exception):
|
class ExportError(Exception):
|
||||||
""" error during export """
|
""" error during export """
|
||||||
@@ -233,9 +236,16 @@ def _export_photo_uuid_applescript(
|
|||||||
exported_files = []
|
exported_files = []
|
||||||
filename = None
|
filename = None
|
||||||
try:
|
try:
|
||||||
photo = photoscript.Photo(uuid)
|
# I've seen intermittent failures with the PhotoScript export so retry if
|
||||||
filename = photo.filename
|
# export doesn't return anything
|
||||||
exported_files = photo.export(tmpdir.name, original=original, timeout=timeout)
|
retries = 0
|
||||||
|
while not exported_files and retries < MAX_PHOTOSCRIPT_RETRIES:
|
||||||
|
photo = photoscript.Photo(uuid)
|
||||||
|
filename = photo.filename
|
||||||
|
exported_files = photo.export(
|
||||||
|
tmpdir.name, original=original, timeout=timeout
|
||||||
|
)
|
||||||
|
retries += 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ExportError(e)
|
raise ExportError(e)
|
||||||
|
|
||||||
@@ -268,7 +278,7 @@ def _export_photo_uuid_applescript(
|
|||||||
exported_paths.append(str(dest_new))
|
exported_paths.append(str(dest_new))
|
||||||
return exported_paths
|
return exported_paths
|
||||||
else:
|
else:
|
||||||
return None
|
return []
|
||||||
|
|
||||||
|
|
||||||
# _check_export_suffix is not a class method, don't import this into PhotoInfo
|
# _check_export_suffix is not a class method, don't import this into PhotoInfo
|
||||||
|
|||||||
Reference in New Issue
Block a user