Spaces:
Running
Running
Download scripts/setup_assets.py from dAAAb/Reachy-Follow-Me: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/spaces/dAAAb/Reachy-Follow-Me/resolve/main/scripts/setup_assets.py
- Command line
-
hf download hf://spaces/dAAAb/Reachy-Follow-Me/scripts/setup_assets.py
-
curl -L -o setup_assets.py https://huggingface.co/spaces/dAAAb/Reachy-Follow-Me/resolve/main/scripts/setup_assets.py
1.08 kB
| #!/usr/bin/env python3 | |
| """Download pinned public assets, validate SHA256; no code execution, no API keys.""" | |
| import hashlib,json,subprocess,tempfile | |
| from pathlib import Path | |
| ROOT=Path(__file__).resolve().parents[1] | |
| for a in json.loads((ROOT/'assets-manifest.json').read_text()): | |
| target=ROOT/a['path'] | |
| if not target.resolve().is_relative_to(ROOT) or not a['url'].startswith('https://'):raise ValueError('unsafe manifest') | |
| if target.exists() and hashlib.sha256(target.read_bytes()).hexdigest()==a['sha256']:continue | |
| print('Downloading',a['path'],flush=True) | |
| target.parent.mkdir(parents=True,exist_ok=True) | |
| with tempfile.TemporaryDirectory() as tmp: | |
| part=Path(tmp)/'asset' | |
| subprocess.run(['curl','--fail','--location','--proto','=https','--proto-redir','=https','--retry','2','--max-time','900','-o',str(part),a['url']],check=True) | |
| blob=part.read_bytes() | |
| if len(blob)!=a['bytes'] or hashlib.sha256(blob).hexdigest()!=a['sha256']:raise ValueError('checksum mismatch: '+a['path']) | |
| target.write_bytes(blob) | |
| print('Local vision assets verified. Run: python3 server.py') | |