Krammy

Example code api.files.dir()

Jun 22nd, 2021
731
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from pyicloud import PyiCloudService
  2. import sys
  3.  
  4. api = PyiCloudService('xxx@me.com','password')
  5.  
  6. if api.requires_2fa:
  7.     import click
  8.     print("Two-factor authentication required. Your trusted devices are:")
  9.  
  10.     devices = api.trusted_devices
  11.     for i, device in enumerate(devices):
  12.         print(
  13.             "  %s: %s" % (i, device.get('deviceName',
  14.             "SMS to %s" % device.get('phoneNumber')))
  15.         )
  16.  
  17.     device = click.prompt('Which device would you like to use?', default=0)
  18.     device = devices[device]
  19.     if not api.send_verification_code(device):
  20.         print("Failed to send verification code")
  21.         sys.exit(1)
  22.  
  23.     code = click.prompt('Please enter validation code')
  24.     if not api.validate_verification_code(device, code):
  25.         print("Failed to verify verification code")
  26.         sys.exit(1)
  27.  
  28. files = api.files.dir()
  29. for file in files:
  30.     print(file)
  31.  
RAW Paste Data