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