Mercurial > code > home > repos > light9
annotate bin/ascoltami2 @ 2042:8849c9e5da30 main
strip dmx_usb_module/.git dir
author | drewp@bigasterisk.com |
---|---|
date | Mon, 09 May 2022 21:44:04 -0700 |
parents | 5154f5a23e85 |
children |
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 |
1011 | 3 from twisted.internet import reactor |
1866
3c523c71da29
pyflakes cleanups and some refactors
Drew Perttula <drewp@bigasterisk.com>
parents:
1861
diff
changeset
|
4 import sys, optparse, logging |
529 | 5 from rdflib import URIRef |
1533
c962f19c7328
pin gtk version in asco
Drew Perttula <drewp@bigasterisk.com>
parents:
1026
diff
changeset
|
6 import gi |
c962f19c7328
pin gtk version in asco
Drew Perttula <drewp@bigasterisk.com>
parents:
1026
diff
changeset
|
7 gi.require_version('Gst', '1.0') |
c962f19c7328
pin gtk version in asco
Drew Perttula <drewp@bigasterisk.com>
parents:
1026
diff
changeset
|
8 gi.require_version('Gtk', '3.0') |
c962f19c7328
pin gtk version in asco
Drew Perttula <drewp@bigasterisk.com>
parents:
1026
diff
changeset
|
9 |
529 | 10 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
|
11 from light9.ascoltami.playlist import Playlist, NoSuchSong |
788 | 12 from light9.ascoltami.webapp import makeWebApp, songUri, songLocation |
529 | 13 from light9 import networking, showconfig |
1957
a745bee5c419
new process stats visualizers
Drew Perttula <drewp@bigasterisk.com>
parents:
1866
diff
changeset
|
14 from standardservice.scalessetup import gatherProcessStats |
529 | 15 |
1866
3c523c71da29
pyflakes cleanups and some refactors
Drew Perttula <drewp@bigasterisk.com>
parents:
1861
diff
changeset
|
16 from gi.repository import GObject, Gst |
673
865532790e62
asco don't log every web request. too much "GET /time"
Drew Perttula <drewp@bigasterisk.com>
parents:
623
diff
changeset
|
17 |
1957
a745bee5c419
new process stats visualizers
Drew Perttula <drewp@bigasterisk.com>
parents:
1866
diff
changeset
|
18 gatherProcessStats() |
1858 | 19 |
1975 | 20 |
907
cca75951554a
port ascoltami to Gst 1.0, work around the missing message signals
Drew Perttula <drewp@bigasterisk.com>
parents:
868
diff
changeset
|
21 class App(object): |
1858 | 22 |
617
94039df5cdd9
create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents:
536
diff
changeset
|
23 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
|
24 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
|
25 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
|
26 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
|
27 self.playlist = Playlist.fromShow(graph, show) |
529 | 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 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
|
30 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
|
31 self.player.seek(0) |
529 | 32 |
788 | 33 thisSongUri = songUri(graph, URIRef(song)) |
34 | |
617
94039df5cdd9
create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents:
536
diff
changeset
|
35 try: |
788 | 36 nextSong = self.playlist.nextSong(thisSongUri) |
1858 | 37 except NoSuchSong: # we're at the end of the playlist |
617
94039df5cdd9
create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents:
536
diff
changeset
|
38 return |
94039df5cdd9
create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents:
536
diff
changeset
|
39 |
788 | 40 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
|
41 |
1858 | 42 |
617
94039df5cdd9
create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents:
536
diff
changeset
|
43 if __name__ == "__main__": |
907
cca75951554a
port ascoltami to Gst 1.0, work around the missing message signals
Drew Perttula <drewp@bigasterisk.com>
parents:
868
diff
changeset
|
44 Gst.init(None) |
529 | 45 |
617
94039df5cdd9
create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents:
536
diff
changeset
|
46 parser = optparse.OptionParser() |
1858 | 47 parser.add_option( |
48 '--show', | |
49 help='show URI, like http://light9.bigasterisk.com/show/dance2008', | |
50 default=showconfig.showUri()) | |
51 parser.add_option("-v", | |
52 "--verbose", | |
53 action="store_true", | |
617
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") |
1858 | 55 parser.add_option("--twistedlog", |
56 action="store_true", | |
938
c2faa69099e6
asco: display update frequency and dim when updates stop. run slower updates on tablets and phones
drewp@bigasterisk.com
parents:
907
diff
changeset
|
57 help="twisted logging") |
617
94039df5cdd9
create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents:
536
diff
changeset
|
58 (options, args) = parser.parse_args() |
529 | 59 |
617
94039df5cdd9
create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents:
536
diff
changeset
|
60 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
|
61 |
94039df5cdd9
create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents:
536
diff
changeset
|
62 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
|
63 raise ValueError("missing --show http://...") |
1858 | 64 |
617
94039df5cdd9
create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents:
536
diff
changeset
|
65 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
|
66 app = App(graph, URIRef(options.show)) |
938
c2faa69099e6
asco: display update frequency and dim when updates stop. run slower updates on tablets and phones
drewp@bigasterisk.com
parents:
907
diff
changeset
|
67 if options.twistedlog: |
c2faa69099e6
asco: display update frequency and dim when updates stop. run slower updates on tablets and phones
drewp@bigasterisk.com
parents:
907
diff
changeset
|
68 from twisted.python import log as twlog |
c2faa69099e6
asco: display update frequency and dim when updates stop. run slower updates on tablets and phones
drewp@bigasterisk.com
parents:
907
diff
changeset
|
69 twlog.startLogging(sys.stderr) |
907
cca75951554a
port ascoltami to Gst 1.0, work around the missing message signals
Drew Perttula <drewp@bigasterisk.com>
parents:
868
diff
changeset
|
70 reactor.listenTCP(networking.musicPlayer.port, makeWebApp(app)) |
cca75951554a
port ascoltami to Gst 1.0, work around the missing message signals
Drew Perttula <drewp@bigasterisk.com>
parents:
868
diff
changeset
|
71 log.info("listening on %s" % networking.musicPlayer.port) |
cca75951554a
port ascoltami to Gst 1.0, work around the missing message signals
Drew Perttula <drewp@bigasterisk.com>
parents:
868
diff
changeset
|
72 reactor.run() |