From 917a394430ba8a02e0a0fbcdbc035047fd848ef8 Mon Sep 17 00:00:00 2001 From: "hongyi.ren" Date: Sat, 14 Sep 2024 21:05:15 +0800 Subject: [PATCH] sync online ver --- .../glob/manager_core.py | 12 ++++++---- .../glob/manager_server.py | 23 ++++--------------- .../js/comfyui-manager.js | 2 +- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/ComfyUI-ModelScope-Manager/glob/manager_core.py b/ComfyUI-ModelScope-Manager/glob/manager_core.py index 1d221b0..cda9cd2 100644 --- a/ComfyUI-ModelScope-Manager/glob/manager_core.py +++ b/ComfyUI-ModelScope-Manager/glob/manager_core.py @@ -1,5 +1,6 @@ import os import sys +import glob import subprocess import re import shutil @@ -16,7 +17,7 @@ import json import time import yaml import zipfile -import glob +import traceback glob_path = os.path.join(os.path.dirname(__file__)) # ComfyUI-Manager/glob sys.path.append(glob_path) @@ -528,14 +529,16 @@ def is_valid_url(url): return False def get_cached_git(url): - cached_git_repo = [os.path.basename(i) for i in glob.glob("/Users/renhy/tmp/*")] + cached_git_repo = [os.path.basename(i) for i in glob.glob("/mnt/comfyui-test/custom_nodes/*")] repo_name = url.strip().split("/")[-1] + user_name = os.environ["USER_NAME"] if repo_name in cached_git_repo: print(f"Find downloaded custom_node: '{url}") - os.symlink("/Users/renhy/tmp/"+repo_name, "/Users/renhy/ComfyUI/custom_nodes/"+repo_name) + os.symlink("/mnt/comfyui-test/custom_nodes/"+repo_name, "/mnt/comfyui-test/custom_nodes_users/" + user_name + "/" + repo_name) return True return False + def gitclone_install(files, instant_execution=False, msg_prefix=''): print(f"{msg_prefix}Install: {files}") for url in files: @@ -556,7 +559,6 @@ def gitclone_install(files, instant_execution=False, msg_prefix=''): if res != 0: return False else: - # os.system("git clone -v --recursive --progress -- " + url + " " + repo_path) if not get_cached_git(url): repo = git.Repo.clone_from(url, repo_path, recursive=True, progress=GitProgress()) repo.git.clear_cache() @@ -566,13 +568,13 @@ def gitclone_install(files, instant_execution=False, msg_prefix=''): return False except Exception as e: + print(traceback.format_exc()) print(f"Install(git-clone) error: {url} / {e}", file=sys.stderr) return False print("Installation was successful.") return True - def git_pull(path): # Check if the path is a git repository if not os.path.exists(os.path.join(path, '.git')): diff --git a/ComfyUI-ModelScope-Manager/glob/manager_server.py b/ComfyUI-ModelScope-Manager/glob/manager_server.py index a081d08..ae59d32 100644 --- a/ComfyUI-ModelScope-Manager/glob/manager_server.py +++ b/ComfyUI-ModelScope-Manager/glob/manager_server.py @@ -777,14 +777,13 @@ def copy_set_active(files, is_disable, js_path_name='.'): @PromptServer.instance.routes.post("/customnode/install") async def install_custom_node(request): - # if not is_allowed_security_level('middle'): - # print(f"ERROR: To use this action, a security_level of `middle or below` is required. Please contact the administrator.") - # return web.Response(status=403) + if not is_allowed_security_level('middle'): + print(f"ERROR: To use this action, a security_level of `middle or below` is required. Please contact the administrator.") + return web.Response(status=403) json_data = await request.json() - # risky_level = await get_risky_level(json_data['files']) - risky_level = "normal" + risky_level = await get_risky_level(json_data['files']) if not is_allowed_security_level(risky_level): print(f"ERROR: This installation is not allowed in this security_level. Please contact the administrator.") return web.Response(status=404) @@ -886,19 +885,6 @@ async def modelscope_reset_personal_customnodes(request): data = {"Message":"Successfully cleaned personal custom nodes."} return web.Response(text=json.dumps(data), status=200) - -# @PromptServer.instance.routes.post("/customnode/install/pip") -# async def install_custom_node_git_url(request): -# if not is_allowed_security_level('high'): -# print(f"ERROR: To use this feature, you must set '--listen' to a local IP and set the security level to 'middle' or 'weak'. Please contact the administrator.") -# return web.Response(status=403) -# -# packages = await request.text() -# core.pip_install(packages.split(' ')) -# -# return web.Response(status=200) - - @PromptServer.instance.routes.post("/customnode/uninstall") async def uninstall_custom_node(request): if not is_allowed_security_level('middle'): @@ -1683,6 +1669,7 @@ import asyncio async def default_cache_update(): async def get_cache(filename): uri = 'https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/' + filename + print(uri) cache_uri = str(core.simple_hash(uri)) + '_' + filename cache_uri = os.path.join(core.cache_dir, cache_uri) diff --git a/ComfyUI-ModelScope-Manager/js/comfyui-manager.js b/ComfyUI-ModelScope-Manager/js/comfyui-manager.js index a65e3be..da13aa8 100644 --- a/ComfyUI-ModelScope-Manager/js/comfyui-manager.js +++ b/ComfyUI-ModelScope-Manager/js/comfyui-manager.js @@ -1498,4 +1498,4 @@ async function set_default_ui() } } -set_default_ui(); \ No newline at end of file +set_default_ui();