Skip to content

Commit

Permalink
implement configuration reload command
Browse files Browse the repository at this point in the history
  • Loading branch information
shravanasati committed May 22, 2024
1 parent 3770c1c commit c4d6517
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
2 changes: 0 additions & 2 deletions stellapy/configuration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
import logging
import os
from dataclasses import asdict, dataclass
from io import StringIO
Expand Down Expand Up @@ -52,7 +51,6 @@ class Configuration:
Represents the stella configuration.
"""

# todo set custom browser drivers for extending browser support
browser: str
include_only: list[str]
poll_interval: float # milliseconds
Expand Down
31 changes: 13 additions & 18 deletions stellapy/reloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from selenium.common.exceptions import NoSuchElementException
from watchdog.observers import Observer

from stellapy.configuration import Configuration
from stellapy.configuration import Configuration, load_configuration_handle_errors
from stellapy.executor import Executor
from stellapy.logger import log
from stellapy.walker import PatternMatchingEventHandler
Expand Down Expand Up @@ -283,23 +283,18 @@ def manual_input(self) -> None:
"no browser URL is configured, can't refresh browser window",
)

# ! too much black magic required to have configuration reloaded
# ! it's because stop_server calls os._exit and that stops the entire progam because there
# ! is no way to gracefully stop the input thread
# ? maybe use timeout input or process
# elif message == "rc":
# log(
# "stella",
# "attempting to reload configuration, stopping existing commands and browser windows",
# )
# self.stop_server()
# cfg_file, new_config = load_configuration_handle_errors(
# self.config_file
# )
# self.__init__(new_config, self.script.name, cfg_file) # type: ignore
# # ignore above because if self.script was None program would've already quit in __init__
# self.executor.start()
# self.restart()
elif message == "rc":
log(
"stella",
"attempting to reload configuration, stopping existing commands and browser windows",
)
self.stop()
cfg_file, new_config = load_configuration_handle_errors(
self.config_file
)
self.__init__(new_config, self.script.name, cfg_file) # type: ignore
# ignore above because if self.script was None program would've already quit in __init__
self.start()

def stop(self):
try:
Expand Down

0 comments on commit c4d6517

Please sign in to comment.