annotate bin/captureDevice @ 1553:48609cc508e8

capture- first wait time can be longer Ignore-this: d8ef35cd51dd1cc60b217b6f99c0935a
author Drew Perttula <drewp@bigasterisk.com>
date Mon, 22 May 2017 06:42:00 +0000
parents 0aad247a1168
children 2239d5648932
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
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):
1553
48609cc508e8 capture- first wait time can be longer
Drew Perttula <drewp@bigasterisk.com>
parents: 1552
diff changeset
51 firstMoveTime = 5
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
52 settleTime = .5
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
53 def __init__(self, graph):
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
54 self.graph = graph
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
55
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
56 def steps(a, b, n):
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
57 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
58
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
59 startTime = time.time()
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
60 self.captureId = 'cap%s' % (int(startTime) - 1495170000)
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
61 self.toGather = []
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 row = 0
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
64 for ry in steps(0.85, .92, 6):
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
65 xSteps = steps(.24, .45, 12)
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
66 if row % 2:
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
67 xSteps.reverse()
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
68 row += 1
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
69 for rx in xSteps:
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
70 self.toGather.append(DeviceSettings(graph, [
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
71 (L9['device/moving1'], L9['rx'], rx),
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
72 (L9['device/moving1'], L9['ry'], ry),
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
73 ]))
1544
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
74
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
75 self.numPics = 0
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
76 self.settingsCache = set()
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
77 self.step().addErrback(log.error)
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 @inlineCallbacks
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
80 def step(self):
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
81 if not self.toGather:
1544
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
82 reactor.stop()
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
83 return
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
84 settings = self.toGather.pop()
1544
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
85
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
86 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
87 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
88
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
89 d = Deferred()
1553
48609cc508e8 capture- first wait time can be longer
Drew Perttula <drewp@bigasterisk.com>
parents: 1552
diff changeset
90 reactor.callLater(self.firstMoveTime if self.numPics == 0 else self.settleTime,
48609cc508e8 capture- first wait time can be longer
Drew Perttula <drewp@bigasterisk.com>
parents: 1552
diff changeset
91 d.callback, None)
1544
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
92 yield d
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
93 dev = settings.devices()[0]
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
94
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
95 devTail = dev.rsplit('/')[-1]
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
96
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
97 picId = 'pic%s' % self.numPics
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
98 path = '/'.join(['capture', devTail, self.captureId, picId])
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
99 ctx = URIRef('/'.join([showconfig.showUri(), 'capture', devTail, self.captureId,
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
100 'index']))
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
101 uri = URIRef('/'.join([showconfig.showUri(), 'capture', devTail, self.captureId,
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
102 picId]))
1544
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 relOutPath = path + '.jpg'
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
105
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
106 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
107 self.numPics += 1
1544
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
108
1552
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
109 writeCaptureDescription(self.graph, ctx, uri, dev, relOutPath,
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
110 self.settingsCache, settings)
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
111
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
112 reactor.callLater(0, self.step)
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
113
1544
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
114
1552
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 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
117
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
118 class Attrs(PrettyErrorHandler, cyclone.web.RequestHandler):
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
119 def put(self):
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
120 with stats.setAttr.time():
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
121 client, clientSession, settings, sendTime = parseJsonMessage(self.request.body)
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
122 self.set_status(202)
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 def launch(graph):
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
125
0aad247a1168 refactor and fix captureDevice
Drew Perttula <drewp@bigasterisk.com>
parents: 1544
diff changeset
126 cap = Capture(graph)
1544
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
127 reactor.listenTCP(networking.captureDevice.port,
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
128 cyclone.web.Application(handlers=[
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
129 (r'/()', cyclone.web.StaticFileHandler,
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
130 {"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
131 (r'/stats', StatsForCyclone),
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
132 ]),
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
133 interface='::')
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
134 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
135
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
136 def main():
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
137 parser = optparse.OptionParser()
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
138 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
139 help="logging.DEBUG")
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
140 (options, args) = parser.parse_args()
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
141 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
142
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
143 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
144
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
145 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
146 reactor.run()
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
147
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
148 if __name__ == '__main__':
fc5675f5b756 captureDevice tool for sweeping through light settings and grabbing pics
Drew Perttula <drewp@bigasterisk.com>
parents:
diff changeset
149 main()