From 26b3f126c5b90236a332111b1cf7f5daf5a968a4 Mon Sep 17 00:00:00 2001 From: The many faced demon <154847721+themanyfaceddemon@users.noreply.github.com> Date: Mon, 29 Jul 2024 00:23:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=80=D0=B0=D0=B7=D0=B3=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D1=87=D0=B8=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81=D0=BA=D0=B0=D1=87?= =?UTF-8?q?=D0=B8=D0=B2=D0=B0=D0=B5=D0=BC=D0=BE=D0=B3=D0=BE=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=82=D0=B5=D0=BD=D1=82=D0=B0=20(#4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Описание PR'ра Позволяет разгранчить скачиваемый контент с сервера Необходимо: - https://github.com/AngelsAndDemonsDM/DM-Bot-server/pull/104 ### Техническая информация - [ ] PR полностью завершён. - [ ] Мне **НЕ** нужна помощь для завершения PR. - [ ] Проверено на локальной машине. - [ ] Документация обновлена. - [ ] Тесты обновлены / добавлены. ### Изменения changes: NOT --- Code/systems/network/client_unit.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Code/systems/network/client_unit.py b/Code/systems/network/client_unit.py index 5500b32..9224aa0 100755 --- a/Code/systems/network/client_unit.py +++ b/Code/systems/network/client_unit.py @@ -24,7 +24,10 @@ def __init__(self) -> None: self._http_url: str = "" self._socket_url: Tuple[str, int] = ("", 0) self._session: requests.Session = requests.Session() + self._token: Optional[str] = None + self._cur_server_name: Optional[str] = None + self._socket: Optional[socket.socket] = None self._bg_processing: bool = False self._bg_thread: Optional[threading.Thread] = None @@ -46,11 +49,12 @@ def check_server(self, ip: str, port: int = 5000) -> None: response = self._session.get(f"{temp_http_url}/server/check_status", timeout=5) response.raise_for_status() - response_data = response.json() + response_data: dict = response.json() if response_data.get("message") == "Server is online": - server_info = response_data.get("server_info", {}) + server_info: dict = response_data.get("server_info", {}) self._http_url = temp_http_url self._socket_url = (ip, server_info.get("socket_port")) + self._cur_server_name = server_info.get("server_name") def download_server_content(self, progress_callback=None) -> None: try: @@ -61,7 +65,7 @@ def download_server_content(self, progress_callback=None) -> None: raise RuntimeError(f"Error during HTTP request: {e}") archive_path = "content.zip" - content_dir = os.path.join(ROOT_PATH, 'Content', "Servers", self._http_url) + content_dir = os.path.join(ROOT_PATH, 'Content', "Servers", self._cur_server_name) total_size = int(response.headers.get('content-length', 0)) downloaded_size = 0