From 67030b0ebae413eaea3d7b74d6f272afa4c6b32e Mon Sep 17 00:00:00 2001 From: Adam Coddington Date: Sun, 17 May 2015 22:48:43 -0700 Subject: [PATCH] Allow user to specify cookie directory. --- pyicloud/base.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pyicloud/base.py b/pyicloud/base.py index d010fd0..87b3338 100644 --- a/pyicloud/base.py +++ b/pyicloud/base.py @@ -31,7 +31,7 @@ class PyiCloudService(object): pyicloud = PyiCloudService('username@apple.com', 'password') pyicloud.iphone.location() """ - def __init__(self, apple_id, password): + def __init__(self, apple_id, password, cookie_directory=None): self.discovery = None self.client_id = str(uuid.uuid1()).upper() self.user = {'apple_id': apple_id, 'password': password} @@ -45,10 +45,15 @@ class PyiCloudService(object): self._base_system_url = '%s/system/version.json' % self._home_endpoint self._base_webauth_url = '%s/refreshWebAuth' % self._push_endpoint - self._cookie_directory = os.path.join( - tempfile.gettempdir(), - 'pyicloud', - ) + if cookie_directory: + self._cookie_directory = os.path.expanduser( + os.path.normpath(cookie_directory) + ) + else: + self._cookie_directory = os.path.join( + tempfile.gettempdir(), + 'pyicloud', + ) self.session = requests.Session() self.session.verify = False