Mercurial > code > home > repos > light9
annotate bin/effectsequencer @ 1830:8e0e5b3db301
redo collector client to use HTTP
Ignore-this: b1ae4f45bfe31d8ba58d13c68e9f6a87
author | drewp@bigasterisk.com |
---|---|
date | Sat, 09 Jun 2018 17:56:43 +0000 |
parents | b680d6f50a93 |
children | 7772cc48e016 |
rev | line source |
---|---|
1373 | 1 #!bin/python |
2 """ | |
3 plays back effect notes from the timeline | |
4 """ | |
5 from __future__ import division | |
6 from run_local import log | |
7 from twisted.internet import reactor | |
8 from light9.greplin_cyclone import StatsForCyclone | |
1692 | 9 from rdfdb.syncedgraph import SyncedGraph |
1373 | 10 from light9 import networking, showconfig |
11 from greplin import scales | |
12 import optparse, sys, logging | |
13 import cyclone.web | |
14 from rdflib import URIRef | |
1830 | 15 from light9.effect.sequencer import Sequencer, Updates |
16 from light9.collector.collector_client import sendToCollector | |
17 | |
1698
f140153c087c
bring back clientsession which doesn't belong in rdfdb
Drew Perttula <drewp@bigasterisk.com>
parents:
1692
diff
changeset
|
18 from light9 import clientsession |
1373 | 19 |
20 class App(object): | |
21 def __init__(self, show, session): | |
22 self.show = show | |
23 self.session = session | |
24 | |
25 self.graph = SyncedGraph(networking.rdfdb.url, "effectSequencer") | |
26 self.graph.initiallySynced.addCallback(self.launch) | |
27 | |
28 | |
29 self.stats = scales.collection('/', | |
30 scales.PmfStat('sendLevels'), | |
31 scales.PmfStat('getMusic'), | |
32 scales.PmfStat('evals'), | |
33 scales.PmfStat('sendOutput'), | |
34 scales.IntStat('errors'), | |
35 ) | |
36 def launch(self, *args): | |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1373
diff
changeset
|
37 self.seq = Sequencer( |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1373
diff
changeset
|
38 self.graph, |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1373
diff
changeset
|
39 lambda settings: sendToCollector('effectSequencer', self.session, |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1373
diff
changeset
|
40 settings)) |
1373 | 41 |
42 self.cycloneApp = cyclone.web.Application(handlers=[ | |
1776 | 43 (r'/()', cyclone.web.StaticFileHandler, |
44 {"path" : "light9/effect/", "default_filename" : "sequencer.html"}), | |
45 (r'/updates', Updates), | |
1373 | 46 (r'/stats', StatsForCyclone), |
47 ], | |
48 debug=True, | |
1776 | 49 seq=self.seq, |
1373 | 50 graph=self.graph, |
51 stats=self.stats) | |
52 reactor.listenTCP(networking.effectSequencer.port, self.cycloneApp) | |
53 log.info("listening on %s" % networking.effectSequencer.port) | |
54 | |
55 | |
56 if __name__ == "__main__": | |
57 parser = optparse.OptionParser() | |
58 parser.add_option('--show', | |
59 help='show URI, like http://light9.bigasterisk.com/show/dance2008', | |
60 default=showconfig.showUri()) | |
61 parser.add_option("-v", "--verbose", action="store_true", | |
62 help="logging.DEBUG") | |
63 parser.add_option("--twistedlog", action="store_true", | |
64 help="twisted logging") | |
65 clientsession.add_option(parser) | |
66 (options, args) = parser.parse_args() | |
67 log.setLevel(logging.DEBUG if options.verbose else logging.INFO) | |
68 | |
69 if not options.show: | |
70 raise ValueError("missing --show http://...") | |
71 | |
72 session = clientsession.getUri('effectSequencer', options) | |
73 | |
74 app = App(URIRef(options.show), session) | |
75 if options.twistedlog: | |
76 from twisted.python import log as twlog | |
77 twlog.startLogging(sys.stderr) | |
78 reactor.run() |