Mercurial > code > home > repos > light9
annotate bin/effectsequencer @ 1414:c35ec37c3c6e
sequencer reloads effecteval on the fly. plus some /stats support.
Ignore-this: 964f4c9007de6532457e0a507d2106f1
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Fri, 10 Jun 2016 06:56:34 +0000 |
parents | 4a7594476905 |
children | 6fa4288da8a6 |
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 | |
9 from light9.rdfdb.syncedgraph import SyncedGraph | |
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 | |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1373
diff
changeset
|
15 from light9.effect.sequencer import Sequencer, sendToCollector |
1373 | 16 from light9.rdfdb import clientsession |
17 | |
18 class App(object): | |
19 def __init__(self, show, session): | |
20 self.show = show | |
21 self.session = session | |
22 | |
23 self.graph = SyncedGraph(networking.rdfdb.url, "effectSequencer") | |
24 self.graph.initiallySynced.addCallback(self.launch) | |
25 | |
26 | |
27 self.stats = scales.collection('/', | |
28 scales.PmfStat('sendLevels'), | |
29 scales.PmfStat('getMusic'), | |
30 scales.PmfStat('evals'), | |
31 scales.PmfStat('sendOutput'), | |
32 scales.IntStat('errors'), | |
33 ) | |
34 def launch(self, *args): | |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1373
diff
changeset
|
35 self.seq = Sequencer( |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1373
diff
changeset
|
36 self.graph, |
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1373
diff
changeset
|
37 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
|
38 settings)) |
1373 | 39 |
40 self.cycloneApp = cyclone.web.Application(handlers=[ | |
41 (r'/stats', StatsForCyclone), | |
42 ], | |
43 debug=True, | |
44 graph=self.graph, | |
45 stats=self.stats) | |
46 reactor.listenTCP(networking.effectSequencer.port, self.cycloneApp) | |
47 log.info("listening on %s" % networking.effectSequencer.port) | |
48 | |
49 | |
50 if __name__ == "__main__": | |
51 parser = optparse.OptionParser() | |
52 parser.add_option('--show', | |
53 help='show URI, like http://light9.bigasterisk.com/show/dance2008', | |
54 default=showconfig.showUri()) | |
55 parser.add_option("-v", "--verbose", action="store_true", | |
56 help="logging.DEBUG") | |
57 parser.add_option("--twistedlog", action="store_true", | |
58 help="twisted logging") | |
59 clientsession.add_option(parser) | |
60 (options, args) = parser.parse_args() | |
61 log.setLevel(logging.DEBUG if options.verbose else logging.INFO) | |
62 | |
63 if not options.show: | |
64 raise ValueError("missing --show http://...") | |
65 | |
66 session = clientsession.getUri('effectSequencer', options) | |
67 | |
68 app = App(URIRef(options.show), session) | |
69 if options.twistedlog: | |
70 from twisted.python import log as twlog | |
71 twlog.startLogging(sys.stderr) | |
72 reactor.run() |