Mercurial > code > home > repos > light9
annotate bin/captureDevice @ 1552:0aad247a1168
refactor and fix captureDevice
Ignore-this: 6698fdc1670318d0e8eb9e3e5aa9d5cf
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Mon, 22 May 2017 04:46:41 +0000 |
parents | fc5675f5b756 |
children | 48609cc508e8 |
rev | line source |
---|---|
1544
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
1 #!bin/python |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
2 from __future__ import division |
1552
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
3 from rdflib import URIRef |
1544
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
4 from twisted.internet import reactor |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
5 from twisted.internet.defer import inlineCallbacks, Deferred |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
6 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
7 import logging |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
8 import optparse |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
9 import os |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
10 import time |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
11 import treq |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
12 import cyclone.web, cyclone.websocket, cyclone.httpclient |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
13 from greplin import scales |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
14 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
15 from run_local import log |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
16 from lib.cycloneerr import PrettyErrorHandler |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
17 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
18 from light9.namespaces import L9 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
19 from light9 import networking, showconfig |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
20 from light9.rdfdb.syncedgraph import SyncedGraph |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
21 from light9.paint.capture import writeCaptureDescription |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
22 from light9.greplin_cyclone import StatsForCyclone |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
23 from light9.effect.settings import DeviceSettings |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
24 from light9.effect.sequencer import sendToCollector |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
25 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
26 stats = scales.collection('/webServer', scales.PmfStat('setAttr')) |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
27 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
28 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
29 class Camera(object): |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
30 def __init__(self, imageUrl): |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
31 self.imageUrl = imageUrl |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
32 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
33 def takePic(self, uri, writePath): |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
34 log.info('takePic %s', uri) |
1552
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
35 return treq.get(self.imageUrl).addCallbacks(lambda r: self._done(writePath, r), |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
36 log.error) |
1544
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
37 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
38 @inlineCallbacks |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
39 def _done(self, writePath, response): |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
40 jpg = yield response.content() |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
41 try: |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
42 os.makedirs(os.path.dirname(writePath)) |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
43 except OSError: |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
44 pass |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
45 with open(writePath, 'w') as out: |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
46 out.write(jpg) |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
47 log.info('wrote %s', writePath) |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
48 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
49 |
1552
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
50 class Capture(object): |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
51 settleTime = .5 |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
52 def __init__(self, graph): |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
53 self.graph = graph |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
54 |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
55 def steps(a, b, n): |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
56 return [round(a + (b - a) * i / n, 5) for i in range(n)] |
1544
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
57 |
1552
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
58 startTime = time.time() |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
59 self.captureId = 'cap%s' % (int(startTime) - 1495170000) |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
60 self.toGather = [] |
1544
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
61 |
1552
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
62 row = 0 |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
63 for ry in steps(0.85, .92, 6): |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
64 xSteps = steps(.24, .45, 12) |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
65 if row % 2: |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
66 xSteps.reverse() |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
67 row += 1 |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
68 for rx in xSteps: |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
69 self.toGather.append(DeviceSettings(graph, [ |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
70 (L9['device/moving1'], L9['rx'], rx), |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
71 (L9['device/moving1'], L9['ry'], ry), |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
72 ])) |
1544
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
73 |
1552
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
74 self.numPics = 0 |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
75 self.settingsCache = set() |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
76 self.step().addErrback(log.error) |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
77 |
1544
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
78 @inlineCallbacks |
1552
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
79 def step(self): |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
80 if not self.toGather: |
1544
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
81 reactor.stop() |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
82 return |
1552
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
83 settings = self.toGather.pop() |
1544
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
84 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
85 log.info('move to %r', settings) |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
86 yield sendToCollector(client='captureDevice', session='main', settings=settings) |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
87 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
88 d = Deferred() |
1552
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
89 reactor.callLater(self.settleTime, d.callback, None) |
1544
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
90 yield d |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
91 dev = settings.devices()[0] |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
92 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
93 devTail = dev.rsplit('/')[-1] |
1552
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
94 |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
95 picId = 'pic%s' % self.numPics |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
96 path = '/'.join(['capture', devTail, self.captureId, picId]) |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
97 ctx = URIRef('/'.join([showconfig.showUri(), 'capture', devTail, self.captureId, |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
98 'index'])) |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
99 uri = URIRef('/'.join([showconfig.showUri(), 'capture', devTail, self.captureId, |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
100 picId])) |
1544
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
101 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
102 relOutPath = path + '.jpg' |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
103 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
104 yield camera.takePic(uri, os.path.join(showconfig.root(), relOutPath)) |
1552
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
105 self.numPics += 1 |
1544
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
106 |
1552
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
107 writeCaptureDescription(self.graph, ctx, uri, dev, relOutPath, |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
108 self.settingsCache, settings) |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
109 |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
110 reactor.callLater(0, self.step) |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
111 |
1544
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
112 |
1552
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
113 |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
114 camera = Camera('http://dash:8200/picamserve/pic?res=480&resize=480&rotation=180&iso=800&redgain=1.6&bluegain=2&shutter=60000') |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
115 |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
116 class Attrs(PrettyErrorHandler, cyclone.web.RequestHandler): |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
117 def put(self): |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
118 with stats.setAttr.time(): |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
119 client, clientSession, settings, sendTime = parseJsonMessage(self.request.body) |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
120 self.set_status(202) |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
121 |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
122 def launch(graph): |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
123 |
0aad247a1168
refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents:
1544
diff
changeset
|
124 cap = Capture(graph) |
1544
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
125 reactor.listenTCP(networking.captureDevice.port, |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
126 cyclone.web.Application(handlers=[ |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
127 (r'/()', cyclone.web.StaticFileHandler, |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
128 {"path" : "light9/web", "default_filename" : "captureDevice.html"}), |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
129 (r'/stats', StatsForCyclone), |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
130 ]), |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
131 interface='::') |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
132 log.info('serving http on %s', networking.captureDevice.port) |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
133 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
134 def main(): |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
135 parser = optparse.OptionParser() |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
136 parser.add_option("-v", "--verbose", action="store_true", |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
137 help="logging.DEBUG") |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
138 (options, args) = parser.parse_args() |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
139 log.setLevel(logging.DEBUG if options.verbose else logging.INFO) |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
140 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
141 graph = SyncedGraph(networking.rdfdb.url, "captureDevice") |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
142 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
143 graph.initiallySynced.addCallback(lambda _: launch(graph)).addErrback(log.error) |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
144 reactor.run() |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
145 |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
146 if __name__ == '__main__': |
fc5675f5b756
captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
147 main() |