hanpa

pyicloud iPhone battery level

Aug 17th, 2017
687
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. #!/usr/bin/env python                                                                                                                          
  2. from pyicloud import PyiCloudService
  3. api = PyiCloudService('[email protected]','password')
  4.  
  5. if api.requires_2fa:
  6.     import click
  7.     print "Two-factor authentication required. Your trusted devices are:"
  8.  
  9.     devices = api.trusted_devices
  10.     for i, device in enumerate(devices):
  11.         print "  %s: %s" % (i, device.get('deviceName',
  12.                                           "SMS to %s" % device.get('phoneNumber')))
  13.  
  14.     device = click.prompt('Which device would you like to use?', default=0)
  15.     device = devices[device]
  16.     if not api.send_verification_code(device):
  17.         print "Failed to send verification code"
  18.         sys.exit(1)
  19.  
  20.     code = click.prompt('Please enter validation code')
  21.     if not api.validate_verification_code(device, code):
  22.         print "Failed to verify verification code"
  23.         sys.exit(1)
  24.  
  25. print(api.iphone.status()['batteryLevel'])
Advertisement
Add Comment
Please, Sign In to add comment