annotate bin/ascoltami2 @ 903:bca2e8d754aa

tripleFilter optimization on currentState. optimize how often curvecalc rebuilds Subterm objs Ignore-this: 7402387bd9f4f99c2e7ef27b8dcfc4db
author Drew Perttula <drewp@bigasterisk.com>
date Mon, 10 Jun 2013 06:00:48 +0000
parents 224d6cd7e1e4
children cca75951554a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
686
a301a0039c66 buildout and rdflib updates
Drew Perttula <drewp@bigasterisk.com>
parents: 674
diff changeset
1 #!bin/python
868
224d6cd7e1e4 asco use colored logs
Drew Perttula <drewp@bigasterisk.com>
parents: 793
diff changeset
2 from run_local import log
793
cbfed4e684ef redo asco web server to use twisted/cyclone. mainloop is now glib inside twisted. seems ok (and lower cpu usage) but not well tested
drewp@bigasterisk.com
parents: 788
diff changeset
3 from twisted.internet import gtk2reactor, reactor
529
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
4 import web, thread, gobject, sys, optparse, logging
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
5 from rdflib import URIRef
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
6 sys.path.append(".")
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
7 from light9.ascoltami.player import Player
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
8 from light9.ascoltami.playlist import Playlist, NoSuchSong
788
8d87a3528369 go button support
drewp@bigasterisk.com
parents: 686
diff changeset
9 from light9.ascoltami.webapp import makeWebApp, songUri, songLocation
529
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
10 from light9 import networking, showconfig
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
11
673
865532790e62 asco don't log every web request. too much "GET /time"
Drew Perttula <drewp@bigasterisk.com>
parents: 623
diff changeset
12
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
13 class App:
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
14 def __init__(self, graph, show):
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
15 self.graph = graph
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
16 self.player = Player(onEOS=self.onEOS)
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
17 self.show = show
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
18 self.playlist = Playlist.fromShow(graph, show)
529
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
19
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
20 def run(self, musicPort):
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
21 # the cherrypy server would wedge when vidref pounds on it; this
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
22 # one seems to run
793
cbfed4e684ef redo asco web server to use twisted/cyclone. mainloop is now glib inside twisted. seems ok (and lower cpu usage) but not well tested
drewp@bigasterisk.com
parents: 788
diff changeset
23 #gtk2reactor.install(useGtk=False)
cbfed4e684ef redo asco web server to use twisted/cyclone. mainloop is now glib inside twisted. seems ok (and lower cpu usage) but not well tested
drewp@bigasterisk.com
parents: 788
diff changeset
24 reactor.listenTCP(musicPort, makeWebApp(self))
cbfed4e684ef redo asco web server to use twisted/cyclone. mainloop is now glib inside twisted. seems ok (and lower cpu usage) but not well tested
drewp@bigasterisk.com
parents: 788
diff changeset
25 log.info("listening on %s" % musicPort)
cbfed4e684ef redo asco web server to use twisted/cyclone. mainloop is now glib inside twisted. seems ok (and lower cpu usage) but not well tested
drewp@bigasterisk.com
parents: 788
diff changeset
26 reactor.run()
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
27
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
28 def onEOS(self, song):
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
29 self.player.pause()
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
30 self.player.seek(0)
529
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
31
788
8d87a3528369 go button support
drewp@bigasterisk.com
parents: 686
diff changeset
32 thisSongUri = songUri(graph, URIRef(song))
8d87a3528369 go button support
drewp@bigasterisk.com
parents: 686
diff changeset
33
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
34 try:
788
8d87a3528369 go button support
drewp@bigasterisk.com
parents: 686
diff changeset
35 nextSong = self.playlist.nextSong(thisSongUri)
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
36 except NoSuchSong: # we're at the end of the playlist
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
37 return
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
38
788
8d87a3528369 go button support
drewp@bigasterisk.com
parents: 686
diff changeset
39 self.player.setSong(songLocation(graph, nextSong), play=False)
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
40
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
41 if __name__ == "__main__":
793
cbfed4e684ef redo asco web server to use twisted/cyclone. mainloop is now glib inside twisted. seems ok (and lower cpu usage) but not well tested
drewp@bigasterisk.com
parents: 788
diff changeset
42 gobject.threads_init() # this is in gtk2reactor too
529
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
43
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
44 parser = optparse.OptionParser()
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
45 parser.add_option('--show',
623
46d319974176 move networking settings to config.n3
drewp@bigasterisk.com
parents: 621
diff changeset
46 help='show URI, like http://light9.bigasterisk.com/show/dance2008', default=showconfig.showUri())
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
47 parser.add_option("-v", "--verbose", action="store_true",
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
48 help="logging.DEBUG")
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
49 (options, args) = parser.parse_args()
529
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
50
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
51 log.setLevel(logging.DEBUG if options.verbose else logging.INFO)
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
52
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
53 if not options.show:
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
54 raise ValueError("missing --show http://...")
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
55
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
56 graph = showconfig.getGraph()
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
57 app = App(graph, URIRef(options.show))
623
46d319974176 move networking settings to config.n3
drewp@bigasterisk.com
parents: 621
diff changeset
58 app.run(networking.musicPlayer.port)