@@ -155,7 +155,7 @@ def _intern(username: str, password: str) -> None:
155155
156156
157157def skip_created_generator (
158- name : str , formatted : str
158+ name : str , formatted : str | None
159159) -> datetime .datetime | datetime .timedelta | None :
160160 """Converts ISO dates to datetime and interval in days to timeinterval using supplied name as part of raised exception in case of the error"""
161161 if formatted is None :
@@ -746,67 +746,6 @@ def delete_photo_dry_run(
746746 )
747747
748748
749- # RetrierT = TypeVar("RetrierT")
750-
751-
752- # def retrier(
753- # func: Callable[[], RetrierT], error_handler: Callable[[Exception, int], None]
754- # ) -> RetrierT:
755- # """Run main func and retry helper if receive session error"""
756- # attempts = 0
757- # while True:
758- # try:
759- # return func()
760- # except Exception as ex:
761- # attempts += 1
762- # error_handler(ex, attempts)
763- # if attempts > constants.MAX_RETRIES:
764- # raise
765-
766-
767- # def session_error_handle_builder(
768- # logger: Logger, icloud: PyiCloudService, ex: Exception, attempt: int
769- # ) -> None:
770- # """Handles session errors in the PhotoAlbum photos iterator"""
771- # if "Invalid global session" in str(ex):
772- # if constants.MAX_RETRIES == 0:
773- # logger.error("Session error, re-authenticating...")
774- # if attempt > constants.MAX_RETRIES:
775- # logger.error("iCloud re-authentication failed. Please try again later.")
776- # raise ex
777- # logger.error("Session error, re-authenticating...")
778- # if attempt > 1:
779- # # If the first re-authentication attempt failed,
780- # # start waiting a few seconds before retrying in case
781- # # there are some issues with the Apple servers
782- # time.sleep(constants.WAIT_SECONDS * attempt)
783- # icloud.authenticate()
784-
785-
786- # def internal_error_handle_builder(logger: logging.Logger, ex: Exception, attempt: int) -> None:
787- # """Handles session errors in the PhotoAlbum photos iterator"""
788- # if "INTERNAL_ERROR" in str(ex):
789- # if attempt > constants.MAX_RETRIES:
790- # logger.error("Internal Error at Apple.")
791- # raise ex
792- # logger.error("Internal Error at Apple, retrying...")
793- # # start waiting a few seconds before retrying in case
794- # # there are some issues with the Apple servers
795- # time.sleep(constants.WAIT_SECONDS * attempt)
796-
797-
798- def compose_handlers (
799- handlers : Sequence [Callable [[Exception , int ], None ]],
800- ) -> Callable [[Exception , int ], None ]:
801- """Compose multiple error handlers"""
802-
803- def composed (ex : Exception , retries : int ) -> None :
804- for handler in handlers :
805- handler (ex , retries )
806-
807- return composed
808-
809-
810749def dump_responses (dumper : Callable [[Any ], None ], responses : List [Mapping [str , Any ]]) -> None :
811750 # dump captured responses
812751 for entry in responses :
@@ -927,15 +866,6 @@ def append_response(captured: List[Mapping[str, Any]], response: Mapping[str, An
927866
928867 logger .debug (f"Looking up all { photo_video_phrase } { album_phrase } ..." )
929868
930- # session_exception_handler = partial(
931- # session_error_handle_builder, logger, icloud
932- # )
933- # internal_error_handler = partial(internal_error_handle_builder, logger)
934-
935- # error_handler = compose_handlers(
936- # [session_exception_handler, internal_error_handler]
937- # )
938-
939869 albums : Iterable [PhotoAlbum ] = (
940870 list (map_ (library_object .albums .__getitem__ , user_config .albums ))
941871 if len (user_config .albums ) > 0
@@ -950,9 +880,6 @@ def sum_(inp: Iterable[int]) -> int:
950880
951881 photos_count : int | None = compose (sum_ , album_lengths )(albums )
952882 for photo_album in albums :
953- # errors are handled at top level now. TODO remove all error handling
954- # photos.exception_handler = error_handler
955-
956883 photos_enumerator : Iterable [PhotoAsset ] = photo_album
957884
958885 # Optional: Only download the x most recent photos.
0 commit comments