From 5b39aec161a0c2455b41342b61b51fdb8df7be03 Mon Sep 17 00:00:00 2001 From: wowlikon Date: Mon, 15 Sep 2025 23:22:48 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7?= =?UTF-8?q?=D0=BA=D0=B8=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2=20=D1=81=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B3=D1=80=D0=B5=D1=81=D1=81-=D0=B1=D0=B0?= =?UTF-8?q?=D1=80=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index 9b147ef..1cf940c 100644 --- a/main.py +++ b/main.py @@ -75,11 +75,19 @@ def run(cmd: List[str], hide_output=True): def download(url: str, dest: Path): console.print(f"[cyan]Скачивание {url} → {dest.name}") - with httpx.stream("GET", url, timeout=30) as r: - r.raise_for_status() - with open(dest, "wb") as f: - for chunk in r.iter_bytes(): - f.write(chunk) + + with httpx.Client(follow_redirects=True, timeout=60.0) as client: + with client.stream("GET", url) as response: + response.raise_for_status() + total = int(response.headers.get("Content-Length", 0)) + + dest.parent.mkdir(parents=True, exist_ok=True) + + with open(dest, "wb") as f, Progress(console=console) as progress: + task = progress.add_task("Загрузка", total=total if total else None) + for chunk in response.iter_bytes(chunk_size=8192): + f.write(chunk) + progress.update(task, advance=len(chunk)) # ======================= INIT ========================= @@ -91,10 +99,9 @@ def init(): if not (TOOLS / "apktool.jar").exists(): download(conf.base.tools.apktool_jar_url, TOOLS / "apktool.jar") - wrapper = httpx.get( - conf.base.tools.apktool_wrapper_url, timeout=30, follow_redirects=True - ).text - (TOOLS / "apktool").write_text(wrapper, encoding="utf-8") + + if not (TOOLS / "apktool").exists(): + download(conf.base.tools.apktool_wrapper_url, TOOLS / "apktool") (TOOLS / "apktool").chmod(0o755) try: