annotate bin/ascoltami2 @ 695:0b8fc64a896c

goocanvas drawing a little Ignore-this: aae191151f454a98caa671b65d080029
author Drew Perttula <drewp@bigasterisk.com>
date Fri, 08 Jun 2012 07:54:32 +0000
parents a301a0039c66
children 8d87a3528369
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
529
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
2 import web, thread, gobject, sys, optparse, logging
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
3 from rdflib import URIRef
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
4 sys.path.append(".")
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
5 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
6 from light9.ascoltami.playlist import Playlist, NoSuchSong
621
9ec0396c6f1f small asco bugs left over from last year
drewp@bigasterisk.com
parents: 617
diff changeset
7 from light9.ascoltami.webapp import makeWebApp
529
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
8 from light9 import networking, showconfig
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
9
673
865532790e62 asco don't log every web request. too much "GET /time"
Drew Perttula <drewp@bigasterisk.com>
parents: 623
diff changeset
10
865532790e62 asco don't log every web request. too much "GET /time"
Drew Perttula <drewp@bigasterisk.com>
parents: 623
diff changeset
11 import BaseHTTPServer
865532790e62 asco don't log every web request. too much "GET /time"
Drew Perttula <drewp@bigasterisk.com>
parents: 623
diff changeset
12 BaseHTTPServer.BaseHTTPRequestHandler.log_message = \
865532790e62 asco don't log every web request. too much "GET /time"
Drew Perttula <drewp@bigasterisk.com>
parents: 623
diff changeset
13 lambda self, format, *args: None
865532790e62 asco don't log every web request. too much "GET /time"
Drew Perttula <drewp@bigasterisk.com>
parents: 623
diff changeset
14
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
15 class App:
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
16 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
17 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
18 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
19 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
20 self.playlist = Playlist.fromShow(graph, show)
529
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
21
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
22 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
23 # 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
24 # one seems to run
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
25 thread.start_new(web.httpserver.runbasic,
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
26 (makeWebApp(self).wsgifunc(),
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
27 ('0.0.0.0', musicPort)))
529
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
28
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
29 mainloop = gobject.MainLoop()
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
30 mainloop.run()
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
31
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
32 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
33 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
34 self.player.seek(0)
529
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
35
674
539de47b68cc asco: fix the EOS catcher instead of the broken duration-.2 hack
Drew Perttula <drewp@bigasterisk.com>
parents: 673
diff changeset
36 # stop here for now- no go-button behavior
539de47b68cc asco: fix the EOS catcher instead of the broken duration-.2 hack
Drew Perttula <drewp@bigasterisk.com>
parents: 673
diff changeset
37 return
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
38 try:
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
39 nextSong = self.playlist.nextSong(song)
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
40 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
41 return
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
42
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
43 self.player.setSong(nextSong, play=False)
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
44
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
45 if __name__ == "__main__":
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
46 logging.basicConfig()
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
47 log = logging.getLogger()
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
48 gobject.threads_init()
529
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
49
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
50 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
51 parser.add_option('--show',
623
46d319974176 move networking settings to config.n3
drewp@bigasterisk.com
parents: 621
diff changeset
52 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
53 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
54 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
55 (options, args) = parser.parse_args()
529
1156d3531327 new ascoltami2, using gstreamer
drewp@bigasterisk.com
parents:
diff changeset
56
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
57 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
58
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
59 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
60 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
61
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 536
diff changeset
62 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
63 app = App(graph, URIRef(options.show))
623
46d319974176 move networking settings to config.n3
drewp@bigasterisk.com
parents: 621
diff changeset
64 app.run(networking.musicPlayer.port)