15 Commits

11 changed files with 116 additions and 19 deletions

View File

@@ -2,6 +2,60 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## [0.3.0] - 2025-09-19
### Bug Fixes
- [`b68c755`](https://github.com/pufereq/template-repo/commit/b68c755c450c7b13f95b335fc93810847306708c) **backend_server.py**: send ack on connect
- [`2922123`](https://github.com/pufereq/template-repo/commit/2922123a7050a9438b024067ebad2901adb84fe3) **backend/__init__.py**: fix backend_server import
- [`c0cacfa`](https://github.com/pufereq/template-repo/commit/c0cacfad2d13799d3472a5d033ae15fd668401f9) **backend_server.py**: fix server waiting for closed socket to dissapear by reusing it in `__init__()`
### Documentation
- [`b9a7c2b`](https://github.com/pufereq/template-repo/commit/b9a7c2bdaf4be8dcea4c6f3196a6092f76eac183) **backend_server.py**: add TODO in `_handle_connection()`
### Features
- [`df0b19d`](https://github.com/pufereq/template-repo/commit/df0b19d94361f63d7ae3def51e3f9360242755b7) **routes/api.py**: support mulitple clients correctly
- [`f2b4811`](https://github.com/pufereq/template-repo/commit/f2b4811145a0a45b2a866aefb095f833c8cb50ae) **backend_server.py**: add `BackendServer._send_ack()` helper method
- [`d5985cf`](https://github.com/pufereq/template-repo/commit/d5985cf5945a304505546ef733631bc33d004621) **__main__.py**: display ascii judas splash screen on launch
- [`b9fd84d`](https://github.com/pufereq/template-repo/commit/b9fd84d08f24bb21e51b48b529f62bfe2671c895) **gaga.py**: add Lady Gaga's Born This Way album art ASCII
- [`c0ad91b`](https://github.com/pufereq/template-repo/commit/c0ad91b22f0e011da1021ead1c126a94aaf90f44) **backend_server.py**: re-add the `get_client_data()` method
- [`2ecd32d`](https://github.com/pufereq/template-repo/commit/2ecd32decce95e6aec74433ef3255bc4cf3c3988) **client.py**: add `Client` class
- [`1c96390`](https://github.com/pufereq/template-repo/commit/1c96390f3cade804b2667bb69bec4419703a6d56) **backend_server.py**: add error handling for HELLO message handler in `_accept_connection()`
- [`639e1f7`](https://github.com/pufereq/template-repo/commit/639e1f73a07286bce1a1ef227d216a722e3fa214) **server.py**: add socket-based communication
### Miscellaneous Tasks
- [`54512d8`](https://github.com/pufereq/template-repo/commit/54512d8393a32f59a9aaddf5a52cb18ee9986fdf) **routes/api.py**: adapt `emit_polled_data()` for `Client` class
- [`ac66ce1`](https://github.com/pufereq/template-repo/commit/ac66ce19998a4518a346b6608645486121cd2123) **backend_server.py**: set `Client.last_seen` on message receive
### Refactor
- [`0d074ad`](https://github.com/pufereq/template-repo/commit/0d074adc0d441428baac6858ff57717f3164cf6a) **backend_server.py**: use `_send_ack()` in `_handle_connection()`
- [`ac77992`](https://github.com/pufereq/template-repo/commit/ac7799213cba82dbb189919873130647d7c87a78) **__main__.py**: provide `host` and `port` args to `BackendServer` explicitly
- [`b5670e5`](https://github.com/pufereq/template-repo/commit/b5670e5d2cf08a031b99478de57aa53cba78bd5b) **server.py**: rename `server.py` to `backend_server.py` for clarity
### Styling
- [`6bbb152`](https://github.com/pufereq/template-repo/commit/6bbb152ae1b1178aa77cf54c6e0f544a0fed66ef) **panel.py**: order imports
- [`b14541e`](https://github.com/pufereq/template-repo/commit/b14541ea8302679091b519e3b6f630fabc0ce476) **index.py**: order imports
- [`7d36e6e`](https://github.com/pufereq/template-repo/commit/7d36e6e43132a687d0494f14f36d9b4dc357abaf) **auth.py**: order imports
- [`98c49b1`](https://github.com/pufereq/template-repo/commit/98c49b1d0d9bb7653a12c7558b5e6daf62a7762b) **api.py**: order imports
- [`377a846`](https://github.com/pufereq/template-repo/commit/377a846c5982be129724a84b4b77a6fb69fd03df) **client.py**: order imports
- [`a27b5b1`](https://github.com/pufereq/template-repo/commit/a27b5b1275fadfb2049fa5e5c535b6667ae37ab5) **backend_server.py**: order imports
- [`19aa80a`](https://github.com/pufereq/template-repo/commit/19aa80a08ebe65685209678b5daf061ffbf19840) **__main__.py**: order imports
- [`f7f6f19`](https://github.com/pufereq/template-repo/commit/f7f6f19808b19ae95bc361d00123a13c4afd344d) **__main__.py**: organize imports
- [`cafef5e`](https://github.com/pufereq/template-repo/commit/cafef5ed932ea5456260398b44e42d71702a386a) **backend_server.py**: remove unused imports
### Build
- [`66db11c`](https://github.com/pufereq/template-repo/commit/66db11c40b34d5315eda2a7dc19cd8ae428ae862) add ruff lint depedency
- [`d96fec0`](https://github.com/pufereq/template-repo/commit/d96fec0222bbf707bc1aa48a6d215dbfec93f159) **web_server.py**: order imports
- [`a1b28fa`](https://github.com/pufereq/template-repo/commit/a1b28faa9ff30ddf9da4e882c0bbac27f4863480) add isort as lint depedency
- [`4e16a70`](https://github.com/pufereq/template-repo/commit/4e16a70174a4492ec59a2ff356deddd758e3e6e1) **uv.lock**: add depedency on judas_protocol
- [`4aa2ca4`](https://github.com/pufereq/template-repo/commit/4aa2ca426c2ae3ac29724f70aa9a07e7eb5a723b) **pyproject.toml**: add depedency on judas_protocol
## [0.2.0] - 2025-08-26 ## [0.2.0] - 2025-08-26
### Bug Fixes ### Bug Fixes

View File

@@ -4,7 +4,7 @@ build-backend = "uv_build"
[project] [project]
name = "judas_server" name = "judas_server"
version = "0.2.0" version = "0.3.0"
description = "The backbone of the remote PC fleet management system." description = "The backbone of the remote PC fleet management system."
readme = "README.md" readme = "README.md"
authors = [] authors = []
@@ -19,6 +19,10 @@ license = { text = "GPL-3.0+" }
[dependency-groups] [dependency-groups]
bump = ["git-cliff>=2.9.1", "python-semantic-release>=10.2.0"] bump = ["git-cliff>=2.9.1", "python-semantic-release>=10.2.0"]
lint = [
"isort>=6.0.1",
"ruff>=0.13.1",
]
test = [ test = [
"pytest>=4.2.1", "pytest>=4.2.1",
"pytest-cov>=6.2.1", "pytest-cov>=6.2.1",

View File

@@ -4,8 +4,8 @@ import logging as lg
if __name__ == "__main__": if __name__ == "__main__":
from judas_server.backend import BackendServer from judas_server.backend import BackendServer
from judas_server.web.web_server import JudasWebServer
from judas_server.gaga import LADY_GAGA from judas_server.gaga import LADY_GAGA
from judas_server.web.web_server import JudasWebServer
lg.basicConfig( lg.basicConfig(
level=lg.DEBUG, level=lg.DEBUG,

View File

@@ -2,10 +2,10 @@
from __future__ import annotations from __future__ import annotations
import logging as lg import logging as lg
import threading
import time
import selectors import selectors
import socket import socket
import threading
import time
from judas_protocol import Message from judas_protocol import Message
@@ -109,6 +109,8 @@ class BackendServer:
client = Client(id_=mac_id, addr=addr, socket=conn) client = Client(id_=mac_id, addr=addr, socket=conn)
self.clients[mac_id] = client self.clients[mac_id] = client
self._send_ack(client)
events = selectors.EVENT_READ | selectors.EVENT_WRITE events = selectors.EVENT_READ | selectors.EVENT_WRITE
self.selector.register(conn, events, data=client) self.selector.register(conn, events, data=client)

View File

@@ -5,7 +5,6 @@ from __future__ import annotations
import logging as lg import logging as lg
import socket import socket
from enum import Enum from enum import Enum

View File

@@ -1,12 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import annotations from __future__ import annotations
import threading
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import flask import flask
import flask_login import flask_login
import threading
import logging as lg
if TYPE_CHECKING: if TYPE_CHECKING:
from werkzeug.wrappers import Response from werkzeug.wrappers import Response
@@ -52,9 +51,10 @@ def emit_polled_data(app, socketio):
import time import time
while True: while True:
data = {}
for client_id in backend.clients.keys(): for client_id in backend.clients.keys():
data = backend.get_client_data(client_id) data[client_id] = backend.get_client_data(client_id)
socketio.emit("update_data", {client_id: data}) socketio.emit("update_data", data)
time.sleep(1) time.sleep(1)

View File

@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import annotations from __future__ import annotations
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import flask import flask

View File

@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import annotations from __future__ import annotations
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import flask import flask
import flask_login import flask_login
if TYPE_CHECKING: if TYPE_CHECKING:
from werkzeug.wrappers import Response from werkzeug.wrappers import Response

View File

@@ -4,7 +4,6 @@ from __future__ import annotations
import flask import flask
import flask_login import flask_login
panel_bp: flask.Blueprint = flask.Blueprint( panel_bp: flask.Blueprint = flask.Blueprint(
"panel", __name__, url_prefix="/panel" "panel", __name__, url_prefix="/panel"
) )

View File

@@ -53,12 +53,7 @@ class JudasWebServer:
def init_routes(self) -> None: def init_routes(self) -> None:
self.logger.debug("Initializing routes...") self.logger.debug("Initializing routes...")
from judas_server.web.routes import ( from judas_server.web.routes import api, auth_bp, index_bp, panel_bp
auth_bp,
index_bp,
panel_bp,
api,
)
self.app.register_blueprint(index_bp) self.app.register_blueprint(index_bp)
self.app.register_blueprint(auth_bp) self.app.register_blueprint(auth_bp)

45
uv.lock generated
View File

@@ -287,6 +287,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/2c/e1/e6716421ea10d38022b952c159d5161ca1193197fb744506875fbb87ea7b/iniconfig-2.1.0-py3-none-any.whl", hash = "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760", size = 6050, upload-time = "2025-03-19T20:10:01.071Z" }, { url = "https://files.pythonhosted.org/packages/2c/e1/e6716421ea10d38022b952c159d5161ca1193197fb744506875fbb87ea7b/iniconfig-2.1.0-py3-none-any.whl", hash = "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760", size = 6050, upload-time = "2025-03-19T20:10:01.071Z" },
] ]
[[package]]
name = "isort"
version = "6.0.1"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/b8/21/1e2a441f74a653a144224d7d21afe8f4169e6c7c20bb13aec3a2dc3815e0/isort-6.0.1.tar.gz", hash = "sha256:1cb5df28dfbc742e490c5e41bad6da41b805b0a8be7bc93cd0fb2a8a890ac450", size = 821955, upload-time = "2025-02-26T21:13:16.955Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/c1/11/114d0a5f4dabbdcedc1125dee0888514c3c3b16d3e9facad87ed96fad97c/isort-6.0.1-py3-none-any.whl", hash = "sha256:2dc5d7f65c9678d94c88dfc29161a320eec67328bc97aad576874cb4be1e9615", size = 94186, upload-time = "2025-02-26T21:13:14.911Z" },
]
[[package]] [[package]]
name = "itsdangerous" name = "itsdangerous"
version = "2.2.0" version = "2.2.0"
@@ -315,7 +324,7 @@ source = { git = "https://gitea.pufereq.pl/judas/judas_protocol.git#fd070b176347
[[package]] [[package]]
name = "judas-server" name = "judas-server"
version = "0.2.0" version = "0.3.0"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "flask" }, { name = "flask" },
@@ -329,6 +338,10 @@ bump = [
{ name = "git-cliff" }, { name = "git-cliff" },
{ name = "python-semantic-release" }, { name = "python-semantic-release" },
] ]
lint = [
{ name = "isort" },
{ name = "ruff" },
]
test = [ test = [
{ name = "pytest" }, { name = "pytest" },
{ name = "pytest-cov" }, { name = "pytest-cov" },
@@ -349,6 +362,10 @@ bump = [
{ name = "git-cliff", specifier = ">=2.9.1" }, { name = "git-cliff", specifier = ">=2.9.1" },
{ name = "python-semantic-release", specifier = ">=10.2.0" }, { name = "python-semantic-release", specifier = ">=10.2.0" },
] ]
lint = [
{ name = "isort", specifier = ">=6.0.1" },
{ name = "ruff", specifier = ">=0.13.1" },
]
test = [ test = [
{ name = "pytest", specifier = ">=4.2.1" }, { name = "pytest", specifier = ">=4.2.1" },
{ name = "pytest-cov", specifier = ">=6.2.1" }, { name = "pytest-cov", specifier = ">=6.2.1" },
@@ -631,6 +648,32 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/e3/30/3c4d035596d3cf444529e0b2953ad0466f6049528a879d27534700580395/rich-14.1.0-py3-none-any.whl", hash = "sha256:536f5f1785986d6dbdea3c75205c473f970777b4a0d6c6dd1b696aa05a3fa04f", size = 243368, upload-time = "2025-07-25T07:32:56.73Z" }, { url = "https://files.pythonhosted.org/packages/e3/30/3c4d035596d3cf444529e0b2953ad0466f6049528a879d27534700580395/rich-14.1.0-py3-none-any.whl", hash = "sha256:536f5f1785986d6dbdea3c75205c473f970777b4a0d6c6dd1b696aa05a3fa04f", size = 243368, upload-time = "2025-07-25T07:32:56.73Z" },
] ]
[[package]]
name = "ruff"
version = "0.13.1"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/ab/33/c8e89216845615d14d2d42ba2bee404e7206a8db782f33400754f3799f05/ruff-0.13.1.tar.gz", hash = "sha256:88074c3849087f153d4bb22e92243ad4c1b366d7055f98726bc19aa08dc12d51", size = 5397987, upload-time = "2025-09-18T19:52:44.33Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/f3/41/ca37e340938f45cfb8557a97a5c347e718ef34702546b174e5300dbb1f28/ruff-0.13.1-py3-none-linux_armv6l.whl", hash = "sha256:b2abff595cc3cbfa55e509d89439b5a09a6ee3c252d92020bd2de240836cf45b", size = 12304308, upload-time = "2025-09-18T19:51:56.253Z" },
{ url = "https://files.pythonhosted.org/packages/ff/84/ba378ef4129415066c3e1c80d84e539a0d52feb250685091f874804f28af/ruff-0.13.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:4ee9f4249bf7f8bb3984c41bfaf6a658162cdb1b22e3103eabc7dd1dc5579334", size = 12937258, upload-time = "2025-09-18T19:52:00.184Z" },
{ url = "https://files.pythonhosted.org/packages/8d/b6/ec5e4559ae0ad955515c176910d6d7c93edcbc0ed1a3195a41179c58431d/ruff-0.13.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:5c5da4af5f6418c07d75e6f3224e08147441f5d1eac2e6ce10dcce5e616a3bae", size = 12214554, upload-time = "2025-09-18T19:52:02.753Z" },
{ url = "https://files.pythonhosted.org/packages/70/d6/cb3e3b4f03b9b0c4d4d8f06126d34b3394f6b4d764912fe80a1300696ef6/ruff-0.13.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:80524f84a01355a59a93cef98d804e2137639823bcee2931f5028e71134a954e", size = 12448181, upload-time = "2025-09-18T19:52:05.279Z" },
{ url = "https://files.pythonhosted.org/packages/d2/ea/bf60cb46d7ade706a246cd3fb99e4cfe854efa3dfbe530d049c684da24ff/ruff-0.13.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ff7f5ce8d7988767dd46a148192a14d0f48d1baea733f055d9064875c7d50389", size = 12104599, upload-time = "2025-09-18T19:52:07.497Z" },
{ url = "https://files.pythonhosted.org/packages/2d/3e/05f72f4c3d3a69e65d55a13e1dd1ade76c106d8546e7e54501d31f1dc54a/ruff-0.13.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c55d84715061f8b05469cdc9a446aa6c7294cd4bd55e86a89e572dba14374f8c", size = 13791178, upload-time = "2025-09-18T19:52:10.189Z" },
{ url = "https://files.pythonhosted.org/packages/81/e7/01b1fc403dd45d6cfe600725270ecc6a8f8a48a55bc6521ad820ed3ceaf8/ruff-0.13.1-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:ac57fed932d90fa1624c946dc67a0a3388d65a7edc7d2d8e4ca7bddaa789b3b0", size = 14814474, upload-time = "2025-09-18T19:52:12.866Z" },
{ url = "https://files.pythonhosted.org/packages/fa/92/d9e183d4ed6185a8df2ce9faa3f22e80e95b5f88d9cc3d86a6d94331da3f/ruff-0.13.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c366a71d5b4f41f86a008694f7a0d75fe409ec298685ff72dc882f882d532e36", size = 14217531, upload-time = "2025-09-18T19:52:15.245Z" },
{ url = "https://files.pythonhosted.org/packages/3b/4a/6ddb1b11d60888be224d721e01bdd2d81faaf1720592858ab8bac3600466/ruff-0.13.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f4ea9d1b5ad3e7a83ee8ebb1229c33e5fe771e833d6d3dcfca7b77d95b060d38", size = 13265267, upload-time = "2025-09-18T19:52:17.649Z" },
{ url = "https://files.pythonhosted.org/packages/81/98/3f1d18a8d9ea33ef2ad508f0417fcb182c99b23258ec5e53d15db8289809/ruff-0.13.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b0f70202996055b555d3d74b626406476cc692f37b13bac8828acff058c9966a", size = 13243120, upload-time = "2025-09-18T19:52:20.332Z" },
{ url = "https://files.pythonhosted.org/packages/8d/86/b6ce62ce9c12765fa6c65078d1938d2490b2b1d9273d0de384952b43c490/ruff-0.13.1-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:f8cff7a105dad631085d9505b491db33848007d6b487c3c1979dd8d9b2963783", size = 13443084, upload-time = "2025-09-18T19:52:23.032Z" },
{ url = "https://files.pythonhosted.org/packages/a1/6e/af7943466a41338d04503fb5a81b2fd07251bd272f546622e5b1599a7976/ruff-0.13.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:9761e84255443316a258dd7dfbd9bfb59c756e52237ed42494917b2577697c6a", size = 12295105, upload-time = "2025-09-18T19:52:25.263Z" },
{ url = "https://files.pythonhosted.org/packages/3f/97/0249b9a24f0f3ebd12f007e81c87cec6d311de566885e9309fcbac5b24cc/ruff-0.13.1-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:3d376a88c3102ef228b102211ef4a6d13df330cb0f5ca56fdac04ccec2a99700", size = 12072284, upload-time = "2025-09-18T19:52:27.478Z" },
{ url = "https://files.pythonhosted.org/packages/f6/85/0b64693b2c99d62ae65236ef74508ba39c3febd01466ef7f354885e5050c/ruff-0.13.1-py3-none-musllinux_1_2_i686.whl", hash = "sha256:cbefd60082b517a82c6ec8836989775ac05f8991715d228b3c1d86ccc7df7dae", size = 12970314, upload-time = "2025-09-18T19:52:30.212Z" },
{ url = "https://files.pythonhosted.org/packages/96/fc/342e9f28179915d28b3747b7654f932ca472afbf7090fc0c4011e802f494/ruff-0.13.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:dd16b9a5a499fe73f3c2ef09a7885cb1d97058614d601809d37c422ed1525317", size = 13422360, upload-time = "2025-09-18T19:52:32.676Z" },
{ url = "https://files.pythonhosted.org/packages/37/54/6177a0dc10bce6f43e392a2192e6018755473283d0cf43cc7e6afc182aea/ruff-0.13.1-py3-none-win32.whl", hash = "sha256:55e9efa692d7cb18580279f1fbb525146adc401f40735edf0aaeabd93099f9a0", size = 12178448, upload-time = "2025-09-18T19:52:35.545Z" },
{ url = "https://files.pythonhosted.org/packages/64/51/c6a3a33d9938007b8bdc8ca852ecc8d810a407fb513ab08e34af12dc7c24/ruff-0.13.1-py3-none-win_amd64.whl", hash = "sha256:3a3fb595287ee556de947183489f636b9f76a72f0fa9c028bdcabf5bab2cc5e5", size = 13286458, upload-time = "2025-09-18T19:52:38.198Z" },
{ url = "https://files.pythonhosted.org/packages/fd/04/afc078a12cf68592345b1e2d6ecdff837d286bac023d7a22c54c7a698c5b/ruff-0.13.1-py3-none-win_arm64.whl", hash = "sha256:c0bae9ffd92d54e03c2bf266f466da0a65e145f298ee5b5846ed435f6a00518a", size = 12437893, upload-time = "2025-09-18T19:52:41.283Z" },
]
[[package]] [[package]]
name = "shellingham" name = "shellingham"
version = "1.5.4" version = "1.5.4"