Mercurial > code > home > repos > light9
annotate bin/effectsequencer @ 1926:1a7e5b07bf17
use my greplin fork's stats/ code instead of an old local one
Ignore-this: f0935bd61f0b982e544c1991e14fb51e
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Sun, 02 Jun 2019 00:05:12 +0000 |
parents | 91bcc6c76934 |
children | 4718ca6f812e |
rev | line source |
---|---|
1373 | 1 #!bin/python |
2 """ | |
3 plays back effect notes from the timeline | |
4 """ | |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
5 |
1373 | 6 from run_local import log |
7 from twisted.internet import reactor | |
1926
1a7e5b07bf17
use my greplin fork's stats/ code instead of an old local one
Drew Perttula <drewp@bigasterisk.com>
parents:
1924
diff
changeset
|
8 from greplin.scales.cyclonehandler import StatsHandler |
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 |
1858 | 20 |
1373 | 21 class App(object): |
1858 | 22 |
1373 | 23 def __init__(self, show, session): |
24 self.show = show | |
25 self.session = session | |
26 | |
27 self.graph = SyncedGraph(networking.rdfdb.url, "effectSequencer") | |
28 self.graph.initiallySynced.addCallback(self.launch) | |
29 | |
1858 | 30 self.stats = scales.collection( |
31 '/', | |
32 scales.PmfStat('sendLevels'), | |
33 scales.PmfStat('getMusic'), | |
34 scales.PmfStat('evals'), | |
35 scales.PmfStat('sendOutput'), | |
36 scales.IntStat('errors'), | |
37 ) | |
1373 | 38 |
39 def launch(self, *args): | |
1391
4a7594476905
hack up KC so it edits effect strengths instead
Drew Perttula <drewp@bigasterisk.com>
parents:
1373
diff
changeset
|
40 self.seq = Sequencer( |
1858 | 41 self.graph, lambda settings: sendToCollector( |
1924
91bcc6c76934
sequencer can use zmq, it seems, but KC should not
Drew Perttula <drewp@bigasterisk.com>
parents:
1859
diff
changeset
|
42 'effectSequencer', self.session, settings, |
91bcc6c76934
sequencer can use zmq, it seems, but KC should not
Drew Perttula <drewp@bigasterisk.com>
parents:
1859
diff
changeset
|
43 # This seems to be safe here (and lets us get from |
91bcc6c76934
sequencer can use zmq, it seems, but KC should not
Drew Perttula <drewp@bigasterisk.com>
parents:
1859
diff
changeset
|
44 # 20fpx to 40fpx), even though it leads to big stalls |
91bcc6c76934
sequencer can use zmq, it seems, but KC should not
Drew Perttula <drewp@bigasterisk.com>
parents:
1859
diff
changeset
|
45 # if I use it on KC. |
91bcc6c76934
sequencer can use zmq, it seems, but KC should not
Drew Perttula <drewp@bigasterisk.com>
parents:
1859
diff
changeset
|
46 useZmq=True)) |
1373 | 47 |
48 self.cycloneApp = cyclone.web.Application(handlers=[ | |
1858 | 49 (r'/()', cyclone.web.StaticFileHandler, { |
50 "path": "light9/effect/", | |
51 "default_filename": "sequencer.html" | |
52 }), | |
1776 | 53 (r'/updates', Updates), |
1926
1a7e5b07bf17
use my greplin fork's stats/ code instead of an old local one
Drew Perttula <drewp@bigasterisk.com>
parents:
1924
diff
changeset
|
54 (r'/stats/(.*)', StatsHandler, { |
1a7e5b07bf17
use my greplin fork's stats/ code instead of an old local one
Drew Perttula <drewp@bigasterisk.com>
parents:
1924
diff
changeset
|
55 'serverName': 'effectsequencer' |
1a7e5b07bf17
use my greplin fork's stats/ code instead of an old local one
Drew Perttula <drewp@bigasterisk.com>
parents:
1924
diff
changeset
|
56 }), |
1373 | 57 ], |
58 debug=True, | |
1776 | 59 seq=self.seq, |
1373 | 60 graph=self.graph, |
61 stats=self.stats) | |
62 reactor.listenTCP(networking.effectSequencer.port, self.cycloneApp) | |
63 log.info("listening on %s" % networking.effectSequencer.port) | |
64 | |
65 | |
66 if __name__ == "__main__": | |
67 parser = optparse.OptionParser() | |
1858 | 68 parser.add_option( |
69 '--show', | |
1373 | 70 help='show URI, like http://light9.bigasterisk.com/show/dance2008', |
1858 | 71 default=showconfig.showUri()) |
72 parser.add_option("-v", | |
73 "--verbose", | |
74 action="store_true", | |
1373 | 75 help="logging.DEBUG") |
1858 | 76 parser.add_option("--twistedlog", |
77 action="store_true", | |
1373 | 78 help="twisted logging") |
79 clientsession.add_option(parser) | |
80 (options, args) = parser.parse_args() | |
81 log.setLevel(logging.DEBUG if options.verbose else logging.INFO) | |
82 | |
83 if not options.show: | |
84 raise ValueError("missing --show http://...") | |
1858 | 85 |
1373 | 86 session = clientsession.getUri('effectSequencer', options) |
87 | |
88 app = App(URIRef(options.show), session) | |
89 if options.twistedlog: | |
90 from twisted.python import log as twlog | |
91 twlog.startLogging(sys.stderr) | |
92 reactor.run() |