dependencies downloading included in init
This commit is contained in:
+40
@@ -4,6 +4,8 @@ import glob
|
||||
import os
|
||||
import sys
|
||||
from .nnodes import init, get_ext_dir
|
||||
import folder_paths
|
||||
import requests
|
||||
|
||||
NODE_CLASS_MAPPINGS = {}
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {}
|
||||
@@ -27,14 +29,52 @@ def check_module(package):
|
||||
return True
|
||||
except ImportError:
|
||||
return False
|
||||
import zipfile
|
||||
def downloader(link):
|
||||
print("Downloading dependencies...")
|
||||
response = requests.get(link, stream=True)
|
||||
try:
|
||||
os.makedirs(folder_paths.get_temp_directory())
|
||||
except:
|
||||
pass
|
||||
temp_file = os.path.join(folder_paths.get_temp_directory(), "file.zip")
|
||||
with open(temp_file, "wb") as f:
|
||||
for chunk in response.iter_content(chunk_size=1024):
|
||||
if chunk: # Filtra i chunk vuoti
|
||||
f.write(chunk) # Scrivi il chunk nel file
|
||||
|
||||
|
||||
|
||||
|
||||
# Estrai lo zip nella cartella desiderata
|
||||
zip_file = zipfile.ZipFile(temp_file) # Apri il file zip
|
||||
target_dir = os.path.join(folder_paths.folder_names_and_paths["custom_nodes"][0][0],"ComfyUI-N-Nodes","libs","rifle") # Cartella dove estrarre lo zip
|
||||
|
||||
zip_file.extractall(target_dir) # Estrai tutti i file dello zip nella cartella
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if init():
|
||||
py = get_ext_dir("py")
|
||||
files = glob.glob("*.py", root_dir=py, recursive=False)
|
||||
install_and_import('moviepy')
|
||||
install_and_import('cv2')
|
||||
install_and_import('git')
|
||||
install_and_import('zipfile')
|
||||
|
||||
#git clone https://github.com/hzwer/Practical-RIFE.git
|
||||
from git import Repo
|
||||
if not os.path.exists(os.path.join(folder_paths.folder_names_and_paths["custom_nodes"][0][0],"ComfyUI-N-Nodes","libs","rifle")):
|
||||
Repo.clone_from("https://github.com/hzwer/Practical-RIFE.git", os.path.join(folder_paths.folder_names_and_paths["custom_nodes"][0][0],"ComfyUI-N-Nodes","libs","rifle"))
|
||||
#if train_log folder not exists
|
||||
if not os.path.exists(os.path.join(folder_paths.folder_names_and_paths["custom_nodes"][0][0],"ComfyUI-N-Nodes","libs","rifle","train_log")):
|
||||
downloader("https://www.animecast.net/download/RIFE_trained_model_v4.7.zip")
|
||||
#"https://github.com/Nuked88/DreamingAI/raw/main/RIFE_trained_model_v4.7.zip")
|
||||
|
||||
for file in files:
|
||||
try:
|
||||
name = os.path.splitext(file)[0]
|
||||
|
||||
Reference in New Issue
Block a user