Allow user to specify cookie directory.

This commit is contained in:
Adam Coddington 2015-05-17 22:48:43 -07:00
parent 1a3a2bd616
commit 67030b0eba

View file

@ -31,7 +31,7 @@ class PyiCloudService(object):
pyicloud = PyiCloudService('username@apple.com', 'password') pyicloud = PyiCloudService('username@apple.com', 'password')
pyicloud.iphone.location() pyicloud.iphone.location()
""" """
def __init__(self, apple_id, password): def __init__(self, apple_id, password, cookie_directory=None):
self.discovery = None self.discovery = None
self.client_id = str(uuid.uuid1()).upper() self.client_id = str(uuid.uuid1()).upper()
self.user = {'apple_id': apple_id, 'password': password} 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_system_url = '%s/system/version.json' % self._home_endpoint
self._base_webauth_url = '%s/refreshWebAuth' % self._push_endpoint self._base_webauth_url = '%s/refreshWebAuth' % self._push_endpoint
self._cookie_directory = os.path.join( if cookie_directory:
tempfile.gettempdir(), self._cookie_directory = os.path.expanduser(
'pyicloud', os.path.normpath(cookie_directory)
) )
else:
self._cookie_directory = os.path.join(
tempfile.gettempdir(),
'pyicloud',
)
self.session = requests.Session() self.session = requests.Session()
self.session.verify = False self.session.verify = False