PEP-8 style fixes; removing missing imports; fixing ValueError when raising PyiCloudNoDevicesException
This commit is contained in:
parent
565146ac3d
commit
3d87dac040
3 changed files with 31 additions and 16 deletions
|
@ -1,4 +1,3 @@
|
|||
import time
|
||||
import uuid
|
||||
import hashlib
|
||||
import json
|
||||
|
@ -115,7 +114,11 @@ class PyiCloudService(object):
|
|||
def files(self):
|
||||
if not hasattr(self, '_files'):
|
||||
service_root = self.webservices['ubiquity']['url']
|
||||
self._files = UbiquityService(service_root, self.session, self.params)
|
||||
self._files = UbiquityService(
|
||||
service_root,
|
||||
self.session,
|
||||
self.params
|
||||
)
|
||||
return self._files
|
||||
|
||||
@property
|
||||
|
|
|
@ -54,7 +54,7 @@ class FindMyiPhoneServiceManager(object):
|
|||
self._devices[device_id].update(device_info)
|
||||
|
||||
if not self._devices:
|
||||
raise PyiCloudNoDevicesException(message)
|
||||
raise PyiCloudNoDevicesException()
|
||||
|
||||
def __getitem__(self, key):
|
||||
if isinstance(key, int):
|
||||
|
@ -79,8 +79,10 @@ class FindMyiPhoneServiceManager(object):
|
|||
|
||||
|
||||
class AppleDevice(object):
|
||||
def __init__(self, content, session, params, manager,
|
||||
sound_url=None, lost_url=None, message_url=None):
|
||||
def __init__(
|
||||
self, content, session, params, manager,
|
||||
sound_url=None, lost_url=None, message_url=None
|
||||
):
|
||||
self.content = content
|
||||
self.manager = manager
|
||||
self.session = session
|
||||
|
@ -122,26 +124,34 @@ class AppleDevice(object):
|
|||
data=data
|
||||
)
|
||||
|
||||
def display_message (self, subject='Find My iPhone Alert', message="This is a note", sounds=False):
|
||||
def display_message(
|
||||
self, subject='Find My iPhone Alert', message="This is a note",
|
||||
sounds=False
|
||||
):
|
||||
""" Send a request to the device to play a sound.
|
||||
|
||||
It's possible to pass a custom message by changing the `subject`.
|
||||
"""
|
||||
data = json.dumps({'device': self.content['id'],
|
||||
data = json.dumps(
|
||||
{
|
||||
'device': self.content['id'],
|
||||
'subject': subject,
|
||||
'sound': sounds,
|
||||
'userText': True,
|
||||
'text': message
|
||||
})
|
||||
}
|
||||
)
|
||||
self.session.post(
|
||||
self.message_url,
|
||||
params=self.params,
|
||||
data=data
|
||||
)
|
||||
|
||||
def lost_device(self, number,
|
||||
def lost_device(
|
||||
self, number,
|
||||
text='This iPhone has been lost. Please call me.',
|
||||
newpasscode=""):
|
||||
newpasscode=""
|
||||
):
|
||||
""" Send a request to the device to trigger 'lost mode'.
|
||||
|
||||
The device will show the message in `text`, and if a number has
|
||||
|
|
|
@ -97,7 +97,9 @@ class UbiquityNode(object):
|
|||
return self.connection.get_file(self.item_id, **kwargs)
|
||||
|
||||
def get(self, name):
|
||||
return [child for child in self.get_children() if child.name == name][0]
|
||||
return [
|
||||
child for child in self.get_children() if child.name == name
|
||||
][0]
|
||||
|
||||
def __getitem__(self, key):
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue