changeset 2049:1aa9a1293611

asco gets a better launcher with vite in it
author drewp@bigasterisk.com
date Wed, 11 May 2022 00:06:19 -0700
parents 53dd7eb024c9
children 7ed414bdaab9
files bin/ascoltami bin/ascoltami2 light9/ascoltami/main.py light9/ascoltami/vite.config.ts
diffstat 4 files changed, 91 insertions(+), 72 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/ascoltami	Wed May 11 00:06:19 2022 -0700
@@ -0,0 +1,4 @@
+#!/bin/zsh
+pnpx vite -c light9/ascoltami/vite.config.ts &
+PYTHONPATH=`pwd` pdm run python light9/ascoltami/main.py
+wait
--- a/bin/ascoltami2	Wed May 11 00:03:44 2022 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-#!bin/python
-from run_local import log
-from twisted.internet import reactor
-import sys, optparse, logging
-from rdflib import URIRef
-import gi
-gi.require_version('Gst', '1.0')
-gi.require_version('Gtk', '3.0')
-
-from light9.ascoltami.player import Player
-from light9.ascoltami.playlist import Playlist, NoSuchSong
-from light9.ascoltami.webapp import makeWebApp, songUri, songLocation
-from light9 import networking, showconfig
-from standardservice.scalessetup import gatherProcessStats
-
-from gi.repository import GObject, Gst
-
-gatherProcessStats()
-
-
-class App(object):
-
-    def __init__(self, graph, show):
-        self.graph = graph
-        self.player = Player(onEOS=self.onEOS)
-        self.show = show
-        self.playlist = Playlist.fromShow(graph, show)
-
-    def onEOS(self, song):
-        self.player.pause()
-        self.player.seek(0)
-
-        thisSongUri = songUri(graph, URIRef(song))
-
-        try:
-            nextSong = self.playlist.nextSong(thisSongUri)
-        except NoSuchSong:  # we're at the end of the playlist
-            return
-
-        self.player.setSong(songLocation(graph, nextSong), play=False)
-
-
-if __name__ == "__main__":
-    Gst.init(None)
-
-    parser = optparse.OptionParser()
-    parser.add_option(
-        '--show',
-        help='show URI, like http://light9.bigasterisk.com/show/dance2008',
-        default=showconfig.showUri())
-    parser.add_option("-v",
-                      "--verbose",
-                      action="store_true",
-                      help="logging.DEBUG")
-    parser.add_option("--twistedlog",
-                      action="store_true",
-                      help="twisted logging")
-    (options, args) = parser.parse_args()
-
-    log.setLevel(logging.DEBUG if options.verbose else logging.INFO)
-
-    if not options.show:
-        raise ValueError("missing --show http://...")
-
-    graph = showconfig.getGraph()
-    app = App(graph, URIRef(options.show))
-    if options.twistedlog:
-        from twisted.python import log as twlog
-        twlog.startLogging(sys.stderr)
-    reactor.listenTCP(networking.musicPlayer.port, makeWebApp(app))
-    log.info("listening on %s" % networking.musicPlayer.port)
-    reactor.run()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/light9/ascoltami/main.py	Wed May 11 00:06:19 2022 -0700
@@ -0,0 +1,69 @@
+#!bin/python
+from light9.run_local import log
+from twisted.internet import reactor
+import sys, optparse, logging
+from rdflib import URIRef
+import gi
+gi.require_version('Gst', '1.0')
+gi.require_version('Gtk', '3.0')
+
+from light9.ascoltami.player import Player
+from light9.ascoltami.playlist import Playlist, NoSuchSong
+from light9.ascoltami.webapp import makeWebApp, songUri, songLocation
+from light9 import networking, showconfig
+
+from gi.repository import GObject, Gst
+
+
+class App(object):
+
+    def __init__(self, graph, show):
+        self.graph = graph
+        self.player = Player(onEOS=self.onEOS)
+        self.show = show
+        self.playlist = Playlist.fromShow(graph, show)
+
+    def onEOS(self, song):
+        self.player.pause()
+        self.player.seek(0)
+
+        thisSongUri = songUri(graph, URIRef(song))
+
+        try:
+            nextSong = self.playlist.nextSong(thisSongUri)
+        except NoSuchSong:  # we're at the end of the playlist
+            return
+
+        self.player.setSong(songLocation(graph, nextSong), play=False)
+
+
+if __name__ == "__main__":
+    Gst.init(None)
+
+    parser = optparse.OptionParser()
+    parser.add_option(
+        '--show',
+        help='show URI, like http://light9.bigasterisk.com/show/dance2008',
+        default=showconfig.showUri())
+    parser.add_option("-v",
+                      "--verbose",
+                      action="store_true",
+                      help="logging.DEBUG")
+    parser.add_option("--twistedlog",
+                      action="store_true",
+                      help="twisted logging")
+    (options, args) = parser.parse_args()
+
+    log.setLevel(logging.DEBUG if options.verbose else logging.INFO)
+
+    if not options.show:
+        raise ValueError("missing --show http://...")
+
+    graph = showconfig.getGraph()
+    app = App(graph, URIRef(options.show))
+    if options.twistedlog:
+        from twisted.python import log as twlog
+        twlog.startLogging(sys.stderr)
+    reactor.listenTCP(networking.musicPlayer.port, makeWebApp(app))
+    log.info("listening on %s" % networking.musicPlayer.port)
+    reactor.run()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/light9/ascoltami/vite.config.ts	Wed May 11 00:06:19 2022 -0700
@@ -0,0 +1,18 @@
+import { defineConfig } from "vite";
+
+export default defineConfig({
+  root: "./light9/ascoltami",
+  publicDir: "../web",
+  server: {
+    host: "0.0.0.0",
+    strictPort: true,
+    port: 8306,
+    hmr: {
+      port: 8406,
+    },
+  },
+  define: {
+    global: {},
+  },
+});
+