toggl-zei-py/main.py

35 lines
726 B
Python
Raw Normal View History

2020-08-12 03:24:23 +02:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import json
2020-08-12 18:44:23 +02:00
from TogglDelegate import TogglDelegate
from zei.Zei import Zei
from zei.ZeiDiscovery import ZeiDiscovery
2020-08-12 03:24:23 +02:00
import logging
2020-08-12 18:44:23 +02:00
2020-08-12 03:24:23 +02:00
_log = logging.getLogger(__name__)
_log.addHandler(logging.StreamHandler())
_log.setLevel(logging.INFO)
2020-08-16 00:00:08 +02:00
2020-08-12 03:24:23 +02:00
def main():
config = json.load(open("./config.json", "r"))
2020-08-16 00:00:08 +02:00
zei = Zei(config["zei"]["mac"], "random", iface=0)
2020-08-12 03:24:23 +02:00
zei.withDelegate(TogglDelegate(zei, config))
scanner = ZeiDiscovery(zei)
while True:
try:
2020-08-16 00:00:08 +02:00
zei.waitForNotifications(timeout=None)
2020-08-12 03:24:23 +02:00
except Exception as e:
_log.exception(e)
scanner.reconnect()
zei.disconnect()
if __name__ == "__main__":
main()