File: example.py

package info (click to toggle)
pyevilgenius 2.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 128 kB
  • sloc: python: 90; makefile: 7
file content (38 lines) | stat: -rw-r--r-- 754 bytes parent folder | download
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
import asyncio
import sys
import logging

import aiohttp

import pyevilgenius


async def main():
    logging.basicConfig(level=logging.DEBUG)
    async with aiohttp.ClientSession() as session:
        await run(session)


async def run(websession):
    if len(sys.argv) < 2:
        print(f"Usage: {sys.argv[0]} <host>")
        return

    host = sys.argv[1]
    device = pyevilgenius.EvilGeniusDevice(host, websession)

    data = await device.get_all()

    for item in data.values():
        if "value" not in item:
            continue
        value = item["value"]
        if "options" in item:
            value = item["options"][value]
        print(f"{item['label']}: {value}")


try:
    asyncio.run(main())
except KeyboardInterrupt:
    pass