Spaces:
Runtime error
Runtime error
Download utils/archive_utils.py from cloudaiRambo/cloudairambo: direct link, hf CLI and curl.
- Browser
- Download file 717 Bytes
-
https://huggingface.co/spaces/cloudaiRambo/cloudairambo/resolve/main/utils/archive_utils.py
- Command line
-
hf download hf://spaces/cloudaiRambo/cloudairambo/utils/archive_utils.py
-
curl -L -o archive_utils.py https://huggingface.co/spaces/cloudaiRambo/cloudairambo/resolve/main/utils/archive_utils.py
717 Bytes
| import subprocess | |
| import os | |
| import uuid | |
| import shutil | |
| from core.config import settings | |
| def extract_archive(input_path: str): | |
| extract_dir = os.path.join(settings.TEMP_DIR, f"extract_{uuid.uuid4()}") | |
| os.makedirs(extract_dir, exist_ok=True) | |
| cmd = ["7z", "x", input_path, f"-o{extract_dir}", "-y"] | |
| subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| return extract_dir | |
| def rezip_folder(folder_path: str, target_ext: str): | |
| output_name = f"{uuid.uuid4()}.{target_ext}" | |
| output_path = os.path.join(settings.OUTPUT_DIR, output_name) | |
| cmd = ["7z", "a", output_path, folder_path] | |
| subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| return output_path | |