Implemented GUI for syng #2

Merged
christofsteel merged 18 commits from gui into main 2023-12-18 19:48:28 +01:00
4 changed files with 25 additions and 9 deletions
Showing only changes of commit 631a408ada - Show all commits

View file

@ -48,6 +48,7 @@ from typing import Optional
import qrcode
import socketio
import engineio
from PIL import Image
from . import jsonencoder
@ -375,8 +376,11 @@ async def handle_request_config(data: dict[str, Any]) -> None:
await sio.emit("config", {"source": data["source"], "config": config})
def terminate(*args):
print("OOPS")
def signal_handler():
engineio.async_client.async_signal_handler()
if state.current_source is not None:
if state.current_source.player is not None:
state.current_source.player.kill()
async def start_client(config: dict[str, Any]) -> None:
@ -408,8 +412,18 @@ async def start_client(config: dict[str, Any]) -> None:
state.config["key"] = ""
await sio.connect(state.config["server"])
await sio.wait()
print("exit")
asyncio.get_event_loop().add_signal_handler(signal.SIGINT, signal_handler)
asyncio.get_event_loop().add_signal_handler(signal.SIGTERM, signal_handler)
try:
await sio.wait()
except asyncio.CancelledError:
pass
finally:
if state.current_source is not None:
if state.current_source.player is not None:
state.current_source.player.kill()
def create_async_and_start_client(config):

View file

@ -322,10 +322,10 @@ class SyngGui(customtkinter.CTk):
)
self.startbutton.pack(side="right")
startserverbutton = customtkinter.CTkButton(
fileframe, text="Start Server", command=self.start_server
)
startserverbutton.pack(side="right")
# startserverbutton = customtkinter.CTkButton(
# fileframe, text="Start Server", command=self.start_server
# )
# startserverbutton.pack(side="right")
open_web_button = customtkinter.CTkButton(
fileframe, text="Open Web", command=self.open_web

View file

@ -18,7 +18,8 @@ class FilesSource(FileBasedSource):
source_name = "files"
config_schema = FileBasedSource.config_schema | {
"dir": (str, "Directory to index", ".")
"dir": (str, "Directory to index", "."),
"index_file": (str, "Index file", "files-index"),
}
def __init__(self, config: dict[str, Any]):

View file

@ -41,6 +41,7 @@ class S3Source(FileBasedSource):
"secure": (bool, "Use SSL", True),
"bucket": (str, "Bucket of the s3", ""),
"tmp_dir": (str, "Folder for\ntemporary download", "/tmp/syng"),
"index_file": (str, "Index file", "s3-index"),
}
def __init__(self, config: dict[str, Any]):