1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
import asyncio
import sys
from pprint import pprint
import aiohttp
from aioeagle import EagleHub
async def main():
async with aiohttp.ClientSession() as session:
await run(session)
async def run(websession):
if len(sys.argv) < 3:
print(f"Usage: {sys.argv[0]} <cloud_id> <install_code>")
return
kwargs = {}
if len(sys.argv) > 3:
kwargs["host"] = sys.argv[3]
hub = EagleHub(websession, sys.argv[1], sys.argv[2], **kwargs)
devices = await hub.get_device_list()
if len(devices) == 0:
print("No devices found")
return
device = devices[0]
pprint(device.details)
print()
pprint(await device.get_device_query())
try:
asyncio.run(main())
except KeyboardInterrupt:
pass
|