forked from info-beamer/package-screen-info
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice
executable file
·44 lines (37 loc) · 1.14 KB
/
service
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
41
42
43
#!/usr/bin/python
import time, traceback, os, sys
# from qrcode.image.pure import PymagingImage
# from qrcode.main import QRCode
from hosted import node, api
# class QRWriter(object):
# def __init__(self, target):
# self._target = target
# def update_img(self, url):
# if os.path.exists(self._target):
# return
# with open(self._target + ".tmp", "wb") as f:
# qr = QRCode(border=2, image_factory=PymagingImage)
# qr.add_data(url)
# im = qr.make_image()
# im.save(f)
# os.rename(self._target + ".tmp", self._target)
# detail_page_qr = QRWriter("device_details.png")
def fetch_info():
info = api.device_info.get()
print >>sys.stderr, info
node['/device_info'](dict(
description = info['description'],
location = info['location'],
))
# detail_page_qr.update_img(info['detail_url'])
if __name__ == "__main__":
interval = 10
while 1:
try:
fetch_info()
interval = 60
except:
traceback.print_exc()
interval = 30
finally:
time.sleep(interval)