You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tinge/tinge/__init__.py.bak

49 lines
1.0 KiB

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import time
import toml
import wx
import HueBridge
from upnpy import UPnP
def connect_new_bridge(ipaddress) -> Bridge:
bridge: Bridge = Bridge(ipaddress)
connected: bool = False
while not connected:
try:
bridge.register_app()
except Exception as mexception: # PhueRegistrationException as mexception:
print(mexception)
time.sleep(5)
else:
connected = True
bridge.connect()
return bridge
class Hui(wx.Frame):
def __init__(self, *args, **kw):
super().__init__(*args, **kw)
self.bridges: list[Bridge] = list()
self.discovered: list[str] = list()
self.config = os.path.join(os.getenv('HOME'), '.tinge')
if is_valid_config(self.config):
self.get_bridges_from_file()
self.discover_new_bridges()
self.write_all_bridges_to_conf()
if __name__ == "__main__":
app = wx.App()
frm = Hui()
# frm.show()
app.MainLoop()