-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathexample.py
47 lines (30 loc) · 846 Bytes
/
example.py
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
44
45
46
47
import asyncio
import sys
from pprint import pprint
import logging
import aiohttp
from aioeagle import EagleHub
logging.basicConfig(level=logging.DEBUG)
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> [ip_address]")
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