-
Notifications
You must be signed in to change notification settings - Fork 1
/
poll_hd.py
executable file
·40 lines (31 loc) · 954 Bytes
/
poll_hd.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
#!/usr/bin/env python
from sink import Sink
from matrix import Matrix
from cctray_status import CCTray
import sys
import time
# USAGE: sudo python poll_hd.py <poll_wait_s> <cctray.xml_url_1> <cctray.xml_url_2> ... <cctray.xml_url_n>
if len(sys.argv) < 3:
print("at least 2 arguments needed")
exit(1)
from RealHatHD import RealHatHD
hat = RealHatHD()
poll_wait_s = int(sys.argv[1])
urls = sys.argv[2:]
#################################################################################
led = Matrix(hat)
sink = Sink(led)
if __name__ == "__main__":
try:
while True:
status = []
for url in urls:
try:
cctray = CCTray(url, hat.AREA)
status += cctray.fetch()
except Exception, e:
print e
sink.put(status)
time.sleep(poll_wait_s)
except KeyboardInterrupt:
hat.off()