annotate bin/captureDevice @ 1584:2239d5648932

captureDevice saves all pics Ignore-this: eae0e07b8f6d4a9b719a1193830f866 it used to drop the last one
author Drew Perttula <drewp@bigasterisk.com>
date Tue, 30 May 2017 07:57:52 +0000
parents 48609cc508e8
children 17da56a3c8df
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
1584
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
49 def deferSleep(sec):
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
50 d = Deferred()
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
51 reactor.callLater(sec, d.callback, None)
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
52 return d
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
53
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
54 class Capture(object):
1584
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
55 firstMoveTime = 3
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
56 settleTime = .5
1584
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
57 def __init__(self, graph, dev):
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
58 self.graph = graph
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
59
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
60 def steps(a, b, n):
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
61 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
62
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
63 startTime = time.time()
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
64 self.captureId = 'cap%s' % (int(startTime) - 1495170000)
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
65 self.toGather = []
1544
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
66
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
67 row = 0
1584
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
68 for ry in steps(0.82, .92, 6):
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
69 xSteps = steps(.23, .42, 12)
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
70 if row % 2:
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
71 xSteps.reverse()
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
72 row += 1
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
73 for rx in xSteps:
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
74 self.toGather.append(DeviceSettings(graph, [
1584
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
75 (dev, L9['rx'], rx),
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
76 (dev, L9['ry'], ry),
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
77 (dev, L9['color'], '#ffffff'),
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
78 ]))
1544
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
79
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
80 self.numPics = 0
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
81 self.settingsCache = set()
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
82 self.step().addErrback(log.error)
1584
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
83
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
84 def off(self):
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
85 return sendToCollector(client='captureDevice', session='main',
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
86 settings=DeviceSettings(self.graph, []))
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
87
1544
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
88 @inlineCallbacks
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
89 def step(self):
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
90 if not self.toGather:
1584
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
91 yield self.off()
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
92 yield deferSleep(1)
1544
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
93 reactor.stop()
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
94 return
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
95 settings = self.toGather.pop()
1544
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
96
1584
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
97 log.info('[%s left] move to %r', len(self.toGather), settings)
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
98 yield sendToCollector(client='captureDevice', session='main',
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
99 settings=settings)
1544
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
100
1584
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
101 yield deferSleep(self.firstMoveTime if self.numPics == 0 else
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
102 self.settleTime)
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
103
1584
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
104 dev = settings.devices()[0]
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
105 devTail = dev.rsplit('/')[-1]
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
106 picId = 'pic%s' % self.numPics
1584
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
107 path = '/'.join(['capture', devTail, self.captureId, picId]) + '.jpg'
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
108 ctx = URIRef('/'.join([showconfig.showUri(),
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
109 'capture', devTail, self.captureId, 'index']))
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
110 uri = URIRef('/'.join([showconfig.showUri(),
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
111 'capture', devTail, self.captureId, picId]))
1544
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
112
1584
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
113 yield camera.takePic(uri, os.path.join(showconfig.root(), path))
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
114 self.numPics += 1
1544
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
115
1584
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
116 writeCaptureDescription(self.graph, ctx, uri, dev, path,
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
117 self.settingsCache, settings)
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
118
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
119 reactor.callLater(0, self.step)
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
120
1544
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
121
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
122
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
123 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
124
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
125 class Attrs(PrettyErrorHandler, cyclone.web.RequestHandler):
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
126 def put(self):
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
127 with stats.setAttr.time():
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
128 client, clientSession, settings, sendTime = parseJsonMessage(self.request.body)
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
129 self.set_status(202)
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
130
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
131 def launch(graph):
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
132
1584
2239d5648932 captureDevice saves all pics
Drew Perttula <drewp@bigasterisk.com>
parents: 1553
diff changeset
133 cap = Capture(graph, dev=L9['device/moving1'])
1544
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
134 reactor.listenTCP(networking.captureDevice.port,
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
135 cyclone.web.Application(handlers=[
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
136 (r'/()', cyclone.web.StaticFileHandler,
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
137 {"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
138 (r'/stats', StatsForCyclone),
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
139 ]),
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
140 interface='::')
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
141 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
142
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
143 def main():
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
144 parser = optparse.OptionParser()
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
145 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
146 help="logging.DEBUG")
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
147 (options, args) = parser.parse_args()
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
148 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
149
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
150 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
151
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
152 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
153 reactor.run()
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
154
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
155 if __name__ == '__main__':
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
156 main()