Skip to content

Commit

Permalink
update: paste latest pyicloud exception classes into pyicloud_ipd/exc…
Browse files Browse the repository at this point in the history
…eptions.py
  • Loading branch information
cfurrow committed Dec 9, 2023
1 parent 91185ca commit b89b99e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 24 deletions.
14 changes: 7 additions & 7 deletions src/pyicloud_ipd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
import http.cookiejar as cookielib
import getpass

from pyicloud_ipd.exceptions import (
PyiCloudConnectionException,
from pyicloud.exceptions import (
PyiCloudFailedLoginException,
PyiCloudAPIResponseError,
PyiCloud2SARequiredError,
PyiCloudServiceNotActivatedErrror
PyiCloudAPIResponseException,
PyiCloud2SARequiredException,
PyiCloudServiceNotActivatedException,
)
from pyicloud_ipd.services import (
from pyicloud.services import (
FindMyiPhoneServiceManager,
CalendarService,
UbiquityService,
ContactsService,
RemindersService,
PhotosService,
AccountService
AccountService,
DriveService,
)
from pyicloud_ipd.utils import get_password_from_keyring

Expand Down
45 changes: 28 additions & 17 deletions src/pyicloud_ipd/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,50 @@

class PyiCloudException(Exception):
pass
"""Library exceptions."""


class PyiCloudConnectionException(PyiCloudException):
pass

class PyiCloudNoDevicesException(PyiCloudException):
class PyiCloudException(Exception):
"""Generic iCloud exception."""
pass


class PyiCloudAPIResponseError(PyiCloudException):
def __init__(self, reason, code):
# API
class PyiCloudAPIResponseException(PyiCloudException):
"""iCloud response exception."""
def __init__(self, reason, code=None, retry=False):
self.reason = reason
self.code = code
message = reason
message = reason or ""
if code:
message += " (%s)" % code
if retry:
message += ". Retrying ..."

super().__init__(message)

super(PyiCloudAPIResponseError, self).__init__(message)

class PyiCloudServiceNotActivatedException(PyiCloudAPIResponseException):
"""iCloud service not activated exception."""
pass


# Login
class PyiCloudFailedLoginException(PyiCloudException):
"""iCloud failed login exception."""
pass


class PyiCloud2SARequiredError(PyiCloudException):
def __init__(self, url):
message = "Two-step authentication required for %s" % url
super(PyiCloud2SARequiredError, self).__init__(message)
class PyiCloud2SARequiredException(PyiCloudException):
"""iCloud 2SA required exception."""
def __init__(self, apple_id):
message = "Two-step authentication required for account: %s" % apple_id
super().__init__(message)


class NoStoredPasswordAvailable(PyiCloudException):
class PyiCloudNoStoredPasswordAvailableException(PyiCloudException):
"""iCloud no stored password exception."""
pass


class PyiCloudServiceNotActivatedErrror(PyiCloudAPIResponseError):
# Webservice specific
class PyiCloudNoDevicesException(PyiCloudException):
"""iCloud no device exception."""
pass

0 comments on commit b89b99e

Please sign in to comment.