mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2025-12-17 02:12:58 +08:00
feat: Try fix
This commit is contained in:
parent
8c730745d6
commit
f243a361c4
56
__init__.py
56
__init__.py
@ -27,7 +27,7 @@ except:
|
|||||||
print(f"[WARN] ComfyUI-Manager: Your ComfyUI version is outdated. Please update to the latest version.")
|
print(f"[WARN] ComfyUI-Manager: Your ComfyUI version is outdated. Please update to the latest version.")
|
||||||
|
|
||||||
|
|
||||||
version = [1, 20]
|
version = [1, 21]
|
||||||
version_str = f"V{version[0]}.{version[1]}" + (f'.{version[2]}' if len(version) > 2 else '')
|
version_str = f"V{version[0]}.{version[1]}" + (f'.{version[2]}' if len(version) > 2 else '')
|
||||||
print(f"### Loading: ComfyUI-Manager ({version_str})")
|
print(f"### Loading: ComfyUI-Manager ({version_str})")
|
||||||
|
|
||||||
@ -1267,6 +1267,30 @@ def gitclone_install(files):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def gitclone_fix(files):
|
||||||
|
print(f"Try fixing: {files}")
|
||||||
|
for url in files:
|
||||||
|
if not is_valid_url(url):
|
||||||
|
print(f"Invalid git url: '{url}'")
|
||||||
|
return False
|
||||||
|
|
||||||
|
if url.endswith("/"):
|
||||||
|
url = url[:-1]
|
||||||
|
try:
|
||||||
|
repo_name = os.path.splitext(os.path.basename(url))[0]
|
||||||
|
repo_path = os.path.join(custom_nodes_path, repo_name)
|
||||||
|
|
||||||
|
if not execute_install_script(url, repo_path):
|
||||||
|
return False
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Install(git-clone) error: {url} / {e}", file=sys.stderr)
|
||||||
|
return False
|
||||||
|
|
||||||
|
print(f"Attempt to fixing '{files}' is done.")
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def pip_install(packages):
|
def pip_install(packages):
|
||||||
install_cmd = ['#FORCE', sys.executable, "-m", "pip", "install", '-U'] + packages
|
install_cmd = ['#FORCE', sys.executable, "-m", "pip", "install", '-U'] + packages
|
||||||
try_install_script('pip install via manager', '.', install_cmd)
|
try_install_script('pip install via manager', '.', install_cmd)
|
||||||
@ -1448,6 +1472,36 @@ async def install_custom_node(request):
|
|||||||
return web.Response(status=400)
|
return web.Response(status=400)
|
||||||
|
|
||||||
|
|
||||||
|
@server.PromptServer.instance.routes.post("/customnode/fix")
|
||||||
|
async def fix_custom_node(request):
|
||||||
|
json_data = await request.json()
|
||||||
|
|
||||||
|
install_type = json_data['install_type']
|
||||||
|
|
||||||
|
print(f"Install custom node '{json_data['title']}'")
|
||||||
|
|
||||||
|
res = False
|
||||||
|
|
||||||
|
if len(json_data['files']) == 0:
|
||||||
|
return web.Response(status=400)
|
||||||
|
|
||||||
|
if install_type == "git-clone":
|
||||||
|
res = gitclone_fix(json_data['files'])
|
||||||
|
else:
|
||||||
|
return web.Response(status=400)
|
||||||
|
|
||||||
|
if 'pip' in json_data:
|
||||||
|
for pname in json_data['pip']:
|
||||||
|
install_cmd = [sys.executable, "-m", "pip", "install", pname]
|
||||||
|
try_install_script(json_data['files'][0], ".", install_cmd)
|
||||||
|
|
||||||
|
if res:
|
||||||
|
print(f"After restarting ComfyUI, please refresh the browser.")
|
||||||
|
return web.json_response({}, content_type='application/json')
|
||||||
|
|
||||||
|
return web.Response(status=400)
|
||||||
|
|
||||||
|
|
||||||
@server.PromptServer.instance.routes.get("/customnode/install/git_url")
|
@server.PromptServer.instance.routes.get("/customnode/install/git_url")
|
||||||
async def install_custom_node_git_url(request):
|
async def install_custom_node_git_url(request):
|
||||||
res = False
|
res = False
|
||||||
|
|||||||
@ -498,6 +498,7 @@ export class CustomNodesInstaller extends ComfyDialog {
|
|||||||
installBtn.className = "cm-btn-install";
|
installBtn.className = "cm-btn-install";
|
||||||
var installBtn2 = null;
|
var installBtn2 = null;
|
||||||
var installBtn3 = null;
|
var installBtn3 = null;
|
||||||
|
var installBtn4 = null;
|
||||||
|
|
||||||
this.install_buttons.push(installBtn);
|
this.install_buttons.push(installBtn);
|
||||||
|
|
||||||
@ -513,6 +514,7 @@ export class CustomNodesInstaller extends ComfyDialog {
|
|||||||
installBtn.innerHTML = 'Uninstall';
|
installBtn.innerHTML = 'Uninstall';
|
||||||
installBtn.style.backgroundColor = 'red';
|
installBtn.style.backgroundColor = 'red';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Update':
|
case 'Update':
|
||||||
installBtn2 = document.createElement('button');
|
installBtn2 = document.createElement('button');
|
||||||
installBtn2.innerHTML = 'Update';
|
installBtn2.innerHTML = 'Update';
|
||||||
@ -531,7 +533,15 @@ export class CustomNodesInstaller extends ComfyDialog {
|
|||||||
installBtn.innerHTML = 'Uninstall';
|
installBtn.innerHTML = 'Uninstall';
|
||||||
installBtn.style.backgroundColor = 'red';
|
installBtn.style.backgroundColor = 'red';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Fail':
|
case 'Fail':
|
||||||
|
installBtn4 = document.createElement('button');
|
||||||
|
installBtn4.innerHTML = 'Try fix';
|
||||||
|
installBtn4.className = "cm-btn-disable";
|
||||||
|
installBtn4.style.backgroundColor = '#6495ED';
|
||||||
|
installBtn4.style.color = 'white';
|
||||||
|
this.install_buttons.push(installBtn4);
|
||||||
|
|
||||||
case 'True':
|
case 'True':
|
||||||
if(manager_instance.update_check_checkbox.checked) {
|
if(manager_instance.update_check_checkbox.checked) {
|
||||||
installBtn2 = document.createElement('button');
|
installBtn2 = document.createElement('button');
|
||||||
@ -582,6 +592,15 @@ export class CustomNodesInstaller extends ComfyDialog {
|
|||||||
data5.appendChild(installBtn3);
|
data5.appendChild(installBtn3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(installBtn4 != null) {
|
||||||
|
installBtn4.style.width = "120px";
|
||||||
|
installBtn4.addEventListener('click', function() {
|
||||||
|
install_checked_custom_node(self.grid_rows, j, CustomNodesInstaller.instance, 'fix');
|
||||||
|
});
|
||||||
|
|
||||||
|
data5.appendChild(installBtn4);
|
||||||
|
}
|
||||||
|
|
||||||
installBtn.style.width = "120px";
|
installBtn.style.width = "120px";
|
||||||
installBtn.addEventListener('click', function() {
|
installBtn.addEventListener('click', function() {
|
||||||
if(this.innerHTML == 'Uninstall') {
|
if(this.innerHTML == 'Uninstall') {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user