Install downloads via proxy-aware llama.py download (fs.download/hf go direct or fail TLS behind corp proxy)
This commit is contained in:
+14
-2
@@ -239,6 +239,18 @@ def login(provider, if_needed=False):
|
||||
except RuntimeError: pass
|
||||
subprocess.run([exe, "login", provider], env=omp_env()) # inherits stdin/stdout: device code / browser URL shown in the Pinokio terminal
|
||||
|
||||
def download(url, dest):
|
||||
"""Proxy-aware, resumable file download (Pinokio's fs.download goes direct and fails where corp DNS only resolves via the proxy; hf's own TLS stack rejects the corp CA). Skips an existing dest."""
|
||||
dest = Path(dest)
|
||||
if dest.exists(): print("kept", dest); return
|
||||
dest.parent.mkdir(parents=True, exist_ok=True); part = dest.with_name(dest.name + ".part")
|
||||
have = part.stat().st_size if part.exists() else 0
|
||||
h = {"User-Agent": "teams-whisper-install", **({"Range": f"bytes={have}-"} if have else {})}
|
||||
with _ropen()(urllib.request.Request(url, headers=h), timeout=900) as r, open(part, "ab" if have and r.status == 206 else "wb") as f: shutil.copyfileobj(r, f, 1 << 20)
|
||||
part.replace(dest); print("downloaded", dest)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if sys.argv[1:] == ["install-omp"]: install_omp()
|
||||
elif sys.argv[1:2] == ["login"]: login(sys.argv[2], "--if-needed" in sys.argv)
|
||||
a = sys.argv[1:]
|
||||
if a == ["install-omp"]: install_omp()
|
||||
elif a[:1] == ["login"]: login(a[1], "--if-needed" in a)
|
||||
elif a[:1] == ["download"]: download(a[1], a[2])
|
||||
|
||||
Reference in New Issue
Block a user