-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkasa-poly.py
executable file
·32 lines (29 loc) · 1.04 KB
/
kasa-poly.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
#!/usr/bin/env python
"""
This is a TP-Link Kasa NodeServer for Polyglot v2 written in Python3
by JimBo [email protected]
"""
import asyncio
import sys
from udi_interface import Interface,LOGGER
import time
import warnings
from nodes import VERSION,Controller
def main():
# Some are getting unclosed socket warnings due to garbage collection?? no idea why, so just ignore them since we dont' care
warnings.filterwarnings("ignore", category=ResourceWarning, message="unclosed.*<socket.socket.*>")
if sys.version_info < (3, 6):
LOGGER.error("ERROR: Python 3.6 or greater is required not {}.{}".format(sys.version_info[0],sys.version_info[1]))
sys.exit(1)
try:
polyglot = Interface([Controller])
polyglot.start(VERSION)
control = Controller(polyglot, 'tplkasactl', 'tplkasactl', 'Kasa Controller')
polyglot.runForever()
except (KeyboardInterrupt, SystemExit):
"""
Catch SIGTERM or Control-C and exit cleanly.
"""
sys.exit(0)
if __name__ == "__main__":
main()