Compare commits
4 Commits
f13f243b5b
...
61be674258
| Author | SHA1 | Date | |
|---|---|---|---|
|
61be674258
|
|||
|
72d51b451f
|
|||
|
efbf99f356
|
|||
|
f46d27164b
|
3
.gitignore
vendored
3
.gitignore
vendored
@@ -45,3 +45,6 @@ logs/
|
|||||||
# Sphinx
|
# Sphinx
|
||||||
docs/_build/
|
docs/_build/
|
||||||
docs/ref/modules/
|
docs/ref/modules/
|
||||||
|
|
||||||
|
# known clients
|
||||||
|
config/known_clients.yaml
|
||||||
|
|||||||
0
cache/.gitkeep
vendored
0
cache/.gitkeep
vendored
@@ -49,9 +49,9 @@ class BackendServer:
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.clients: dict[str, Client] = {}
|
self.clients: dict[str, Client] = {}
|
||||||
self.known_clients: dict[str, dict[str, str | float]] = (
|
|
||||||
self._load_known_clients()
|
self.known_clients: dict[str, dict[str, str | float]] = {}
|
||||||
)
|
self.known_clients = self._load_known_clients()
|
||||||
|
|
||||||
self.message_handlers: dict[
|
self.message_handlers: dict[
|
||||||
tuple[Category, ActionType], Callable[[Client, Message], None]
|
tuple[Category, ActionType], Callable[[Client, Message], None]
|
||||||
@@ -114,8 +114,7 @@ class BackendServer:
|
|||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
"known_clients.yaml not found, creating empty known clients list"
|
"known_clients.yaml not found, creating empty known clients list"
|
||||||
)
|
)
|
||||||
with open("config/known_clients.yaml", "w") as f:
|
self._save_known_clients()
|
||||||
yaml.safe_dump({"known_clients": {}}, f)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error(f"Error loading known clients: {e}")
|
self.logger.error(f"Error loading known clients: {e}")
|
||||||
raise
|
raise
|
||||||
@@ -125,6 +124,11 @@ class BackendServer:
|
|||||||
def _save_known_clients(self) -> None:
|
def _save_known_clients(self) -> None:
|
||||||
"""Save the list of known clients to a YAML file."""
|
"""Save the list of known clients to a YAML file."""
|
||||||
with open("config/known_clients.yaml", "w") as f:
|
with open("config/known_clients.yaml", "w") as f:
|
||||||
|
f.write(
|
||||||
|
"# This file is automatically generated by BackendServer.\n"
|
||||||
|
+ "# Do not edit manually.\n"
|
||||||
|
+ f"# Generated at: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())}\n\n"
|
||||||
|
)
|
||||||
yaml.safe_dump({"known_clients": self.known_clients}, f)
|
yaml.safe_dump({"known_clients": self.known_clients}, f)
|
||||||
self.logger.debug("Saved known clients")
|
self.logger.debug("Saved known clients")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user