| import subprocess |
| import threading |
| import time |
| import os |
|
|
| |
| def check_file_exists(file_path): |
| while os.path.exists(file_path): |
| print(f"等待文件 {file_path} 下载完成...") |
| time.sleep(1) |
| print(f"文件 {file_path} 已下载完成。") |
|
|
| |
| def download_file_A(): |
| download_cmd_A = "cd /root && aria2c -x 16 -s 16 -c -k 1M 'https://www.modelscope.cn/models/ACCC1380/Comfyui_buckup_20241201_1952/resolve/master/ComfyUI.tar.safetensors' -o ComfyUI-aki-v1.3.1.tar" |
| subprocess.run(download_cmd_A, shell=True, check=True) |
|
|
| |
| unzip_cmd = "cd /root && tar -xvf ComfyUI-aki-v1.3.1.tar" |
| subprocess.run(unzip_cmd, shell=True, check=True) |
|
|
| def download_file_B(): |
| time.sleep(3) |
| |
| check_file_exists('/root/ComfyUI-aki-v1.3.1.tar.aria2') |
| |
| download_cmd_B = "cd /root && aria2c -x 16 -s 16 -c -k 1M 'https://www.modelscope.cn/models/ACCC1380/Comfyui_buckup_20241201_1952/resolve/master/cfvenv2.tar.safetensors' -o cfvenv.tar.safetensors -d /root" |
| subprocess.run(download_cmd_B, shell=True, check=True) |
|
|
|
|
| |
| tar_cmd = "cd /root && tar -xvf cfvenv.tar.safetensors" |
| subprocess.run(tar_cmd, shell=True, check=True) |
|
|
|
|
| def extract_and_setup(): |
| |
|
|
|
|
| |
| |
| |
|
|
| |
| run_comfyui_cmd = "cd /root/comfyui/ComfyUI-aki-v1.3.1 && /root/cfvenv/bin/python3 main.py" |
| subprocess.Popen(run_comfyui_cmd, shell=True) |
|
|
| def cleanup(): |
| |
| cleanup_cmd = "rm /root/ComfyUI-aki-v1.3.1.tar && rm /root/cfvenv.tar.safetensors" |
| subprocess.run(cleanup_cmd, shell=True, check=True) |
|
|
| |
| thread_A = threading.Thread(target=download_file_A) |
| thread_B = threading.Thread(target=download_file_B) |
|
|
| thread_A.start() |
| thread_B.start() |
|
|
| |
| thread_A.join() |
| thread_B.join() |
|
|
| |
| extract_and_setup() |
|
|
| |
| cleanup() |
| while True: |
| time.sleep(8888888) |