mirror of
https://github.com/dmunozv04/iSponsorBlockTV.git
synced 2026-03-13 22:12:49 +03:00
Merge pull request #405 from sternma/fix-setup-msg
Fix: unclear setup messages and warnings outside of normal docker config flow
This commit is contained in:
@@ -80,7 +80,9 @@ class Config:
|
|||||||
if i not in config_file_blacklist_keys:
|
if i not in config_file_blacklist_keys:
|
||||||
setattr(self, i, config[i])
|
setattr(self, i, config[i])
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print("Could not load config file")
|
print(
|
||||||
|
f"No config file found, using defaults. Config will be saved to {self.config_file}"
|
||||||
|
)
|
||||||
# Create data directory if it doesn't exist (if we're not running in docker)
|
# Create data directory if it doesn't exist (if we're not running in docker)
|
||||||
if not os.path.exists(self.data_dir):
|
if not os.path.exists(self.data_dir):
|
||||||
if not os.getenv("iSPBTV_docker"):
|
if not os.getenv("iSPBTV_docker"):
|
||||||
@@ -174,7 +176,24 @@ def cli(ctx, data, debug, http_tracing, setup, setup_cli):
|
|||||||
def setup_command(ctx):
|
def setup_command(ctx):
|
||||||
"""Setup the program graphically"""
|
"""Setup the program graphically"""
|
||||||
config = Config(ctx.obj["data_dir"])
|
config = Config(ctx.obj["data_dir"])
|
||||||
|
config_path = config.config_file
|
||||||
|
before_mtime_ns = None
|
||||||
|
try:
|
||||||
|
before_mtime_ns = os.stat(config_path).st_mtime_ns
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
setup_wizard.main(config)
|
setup_wizard.main(config)
|
||||||
|
after_mtime_ns = None
|
||||||
|
try:
|
||||||
|
after_mtime_ns = os.stat(config_path).st_mtime_ns
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
if after_mtime_ns is None:
|
||||||
|
print(f"No config file was saved to {config_path}")
|
||||||
|
elif before_mtime_ns is None or after_mtime_ns != before_mtime_ns:
|
||||||
|
print(f"Config saved to {config_path}")
|
||||||
|
else:
|
||||||
|
print(f"Config unchanged at {config_path}")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -300,6 +300,10 @@ class AddDevice(ModalWithClickExit):
|
|||||||
self.devices_discovered_dial = []
|
self.devices_discovered_dial = []
|
||||||
asyncio.create_task(self.task_discover_devices())
|
asyncio.create_task(self.task_discover_devices())
|
||||||
|
|
||||||
|
async def on_unmount(self) -> None:
|
||||||
|
if not self.web_session.closed:
|
||||||
|
await self.web_session.close()
|
||||||
|
|
||||||
async def task_discover_devices(self):
|
async def task_discover_devices(self):
|
||||||
devices_found = await self.api_helper.discover_youtube_devices_dial()
|
devices_found = await self.api_helper.discover_youtube_devices_dial()
|
||||||
try:
|
try:
|
||||||
@@ -387,8 +391,12 @@ class AddChannel(ModalWithClickExit):
|
|||||||
def __init__(self, config, **kwargs) -> None:
|
def __init__(self, config, **kwargs) -> None:
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.config = config
|
self.config = config
|
||||||
web_session = aiohttp.ClientSession(trust_env=config.use_proxy)
|
self.web_session = aiohttp.ClientSession(trust_env=config.use_proxy)
|
||||||
self.api_helper = api_helpers.ApiHelper(config, web_session)
|
self.api_helper = api_helpers.ApiHelper(config, self.web_session)
|
||||||
|
|
||||||
|
async def on_unmount(self) -> None:
|
||||||
|
if not self.web_session.closed:
|
||||||
|
await self.web_session.close()
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
with Container(id="add-channel-container"):
|
with Container(id="add-channel-container"):
|
||||||
|
|||||||
Reference in New Issue
Block a user