Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions .gitignore

This file was deleted.

Binary file not shown.
66 changes: 66 additions & 0 deletions App Data/backend_client_py.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to backend_client.py no need to state py in name the extension is enogh

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

import subprocess, sys, threading
from pathlib import Path

class BackendProcess:
def __init__(self):
self.proc = None
self.lock = threading.Lock()

def start(self, host: str, port: int, csv_path: str | None = None):
if self.proc and self.proc.poll() is None:
return
# locate script path for dev; use flag for frozen exe
script = str(Path(__file__).parent / "publisher_process.py")
if getattr(sys, 'frozen', False):
# We are running as PyInstaller exe: re-run same exe in backend mode
args = [sys.executable, '--publisher']
creationflags = 0
if os.name == 'nt':
creationflags = 0x08000000 # CREATE_NO_WINDOW (avoid flashing console)
else:
args = [sys.executable, script]
creationflags = 0

self.proc = subprocess.Popen(
args,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
bufsize=1,
creationflags=creationflags
)
threading.Thread(target=self._drain, daemon=True).start()
self.set_server(host, port)
if csv_path:
self.load_csv(csv_path)

def _drain(self):
if not self.proc:
return
for line in self.proc.stderr:
sys.stderr.write("[backend] " + line)

def _send(self, cmd: str):
if not self.proc or self.proc.poll() is not None:
raise RuntimeError("Backend not running")
with self.lock:
self.proc.stdin.write(cmd + "\n")
self.proc.stdin.flush()
return self.proc.stdout.readline().strip()

def set_server(self, host: str, port: int): return self._send(f"SET_SERVER {host} {port}")
def load_csv(self, path: str): return self._send(f"LOAD_CSV {path}")
def seek(self, t: float): return self._send(f"SEEK {t}")
def play(self): return self._send("PLAY")
def pause(self): return self._send("PAUSE")
def stop(self): return self._send("STOP")
def pub_on(self): return self._send("PUBLISH_ON")
def pub_off(self): return self._send("PUBLISH_OFF")
def quit(self):
Comment on lines +53 to +61
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a repetitive and hard to read way to write this, use partial methods to clean this up

try: self._send("QUIT")
except Exception: pass
if self.proc:
self.proc.terminate()
self.proc = None
File renamed without changes.
Binary file added App Data/icon_bw.ico
Binary file not shown.
Binary file added App Data/icon_green.ico
Binary file not shown.
Loading