Some fixups
This commit is contained in:
parent
d19f974e02
commit
ae5d82ce63
3 changed files with 32 additions and 12 deletions
|
@ -4,10 +4,7 @@ Module for the playback client.
|
|||
Excerp from the help::
|
||||
|
||||
usage: client.py [-h] [--room ROOM] [--secret SECRET] \
|
||||
[--config-file CONFIG_FILE] server
|
||||
|
||||
positional arguments:
|
||||
server
|
||||
[--config-file CONFIG_FILE] [--server server]
|
||||
|
||||
options:
|
||||
-h, --help show this help message and exit
|
||||
|
@ -15,6 +12,7 @@ Excerp from the help::
|
|||
--secret SECRET, -s SECRET
|
||||
--config-file CONFIG_FILE, -C CONFIG_FILE
|
||||
--key KEY, -k KEY
|
||||
--server
|
||||
|
||||
The config file should be a yaml file in the following style::
|
||||
|
||||
|
@ -25,11 +23,18 @@ The config file should be a yaml file in the following style::
|
|||
configuration for SOURCE
|
||||
...
|
||||
config:
|
||||
configuration for the client
|
||||
server: ...
|
||||
room: ...
|
||||
preview_duration: ...
|
||||
secret: ...
|
||||
last_song: ...
|
||||
waiting_room_policy: ..
|
||||
|
||||
"""
|
||||
import asyncio
|
||||
import datetime
|
||||
import logging
|
||||
import os
|
||||
import secrets
|
||||
import string
|
||||
import tempfile
|
||||
|
@ -39,6 +44,7 @@ from dataclasses import dataclass
|
|||
from dataclasses import field
|
||||
from traceback import print_exc
|
||||
from typing import Any, Optional
|
||||
import platformdirs
|
||||
|
||||
import qrcode
|
||||
|
||||
|
@ -425,14 +431,21 @@ def main() -> None:
|
|||
|
||||
parser.add_argument("--room", "-r")
|
||||
parser.add_argument("--secret", "-s")
|
||||
parser.add_argument("--config-file", "-C", default="syng-client.yaml")
|
||||
parser.add_argument(
|
||||
"--config-file",
|
||||
"-C",
|
||||
default=f"{os.path.join(platformdirs.user_config_dir('syng'), 'config.yaml')}",
|
||||
)
|
||||
parser.add_argument("--key", "-k", default=None)
|
||||
parser.add_argument("--server", "-S")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
with open(args.config_file, encoding="utf8") as file:
|
||||
config = load(file, Loader=Loader)
|
||||
except FileNotFoundError:
|
||||
config = {}
|
||||
|
||||
if "config" not in config:
|
||||
config["config"] = {}
|
||||
|
|
|
@ -300,9 +300,11 @@ class SyngGui(customtkinter.CTk): # type:ignore
|
|||
def on_close(self) -> None:
|
||||
if self.syng_server is not None:
|
||||
self.syng_server.kill()
|
||||
self.syng_server.join()
|
||||
|
||||
if self.syng_client is not None:
|
||||
self.syng_client.kill()
|
||||
self.syng_client.terminate()
|
||||
self.syng_client.join()
|
||||
|
||||
self.withdraw()
|
||||
self.destroy()
|
||||
|
@ -422,6 +424,7 @@ class SyngGui(customtkinter.CTk): # type:ignore
|
|||
self.startbutton.configure(text="Stop")
|
||||
else:
|
||||
self.syng_client.terminate()
|
||||
self.syng_client.join()
|
||||
self.syng_client = None
|
||||
self.startbutton.configure(text="Save and Start")
|
||||
|
||||
|
|
|
@ -125,6 +125,9 @@ class State:
|
|||
:type sid: str
|
||||
:param client: The config for the playback client
|
||||
:type client: Client
|
||||
:param last_seen: Timestamp of the last connected client. Used to determine
|
||||
if a room is still in use.
|
||||
:type last_seen: datetime
|
||||
"""
|
||||
|
||||
queue: Queue
|
||||
|
@ -156,7 +159,6 @@ async def send_state(state: State, sid: str) -> None:
|
|||
"""
|
||||
|
||||
safe_config = {k: v for k, v in state.client.config.items() if k not in ["secret", "key"]}
|
||||
print(safe_config)
|
||||
|
||||
await sio.emit(
|
||||
"state",
|
||||
|
@ -1085,10 +1087,12 @@ def main() -> None:
|
|||
|
||||
:rtype: None
|
||||
"""
|
||||
|
||||
root_path = os.path.join(os.path.dirname(__file__), "static")
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument("--host", "-H", default="localhost")
|
||||
parser.add_argument("--port", "-p", type=int, default=8080)
|
||||
parser.add_argument("--root-folder", "-r", default="syng/static/")
|
||||
parser.add_argument("--root-folder", "-r", default=root_path)
|
||||
parser.add_argument("--registration-keyfile", "-k", default=None)
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue