now support 'copy' install type for .js

bugfix: local db, message box
This commit is contained in:
Dr.Lt.Data 2023-05-06 20:14:23 +09:00
parent 2e41a8a3bd
commit 7d441ac473
3 changed files with 70 additions and 24 deletions

View File

@ -13,6 +13,7 @@ print("### Loading: ComfyUI-Manager")
comfy_path = os.path.dirname(folder_paths.__file__) comfy_path = os.path.dirname(folder_paths.__file__)
custom_nodes_path = os.path.join(comfy_path, 'custom_nodes') custom_nodes_path = os.path.join(comfy_path, 'custom_nodes')
js_path = os.path.join(comfy_path, "web", "extensions")
comfyui_manager_path = os.path.dirname(__file__) comfyui_manager_path = os.path.dirname(__file__)
local_db_model = os.path.join(comfyui_manager_path, "model-list.json") local_db_model = os.path.join(comfyui_manager_path, "model-list.json")
@ -41,7 +42,7 @@ def setup_js():
os.remove(old_js_path) os.remove(old_js_path)
# setup js # setup js
js_dest_path = os.path.join(comfy_path, "web", "extensions", "comfyui-manager") js_dest_path = os.path.join(js_path, "comfyui-manager")
if not os.path.exists(js_dest_path): if not os.path.exists(js_dest_path):
os.makedirs(js_dest_path) os.makedirs(js_dest_path)
js_src_path = os.path.join(comfyui_manager_path, "js", "comfyui-manager.js") js_src_path = os.path.join(comfyui_manager_path, "js", "comfyui-manager.js")
@ -104,12 +105,14 @@ def check_a_custom_node_installed(item):
elif item['install_type'] == 'copy' and len(item['files']) == 1: elif item['install_type'] == 'copy' and len(item['files']) == 1:
dir_name = os.path.basename(item['files'][0]) dir_name = os.path.basename(item['files'][0])
dir_path = os.path.join(custom_nodes_path, dir_name) base_path = custom_nodes_path if item['files'][0].endswith('.py') else js_path
if os.path.exists(dir_path): file_path = os.path.join(base_path, dir_name)
if os.path.exists(file_path):
item['installed'] = 'True' item['installed'] = 'True'
else: else:
item['installed'] = 'False' item['installed'] = 'False'
def check_custom_nodes_installed(json_obj): def check_custom_nodes_installed(json_obj):
for item in json_obj['custom_nodes']: for item in json_obj['custom_nodes']:
check_a_custom_node_installed(item) check_a_custom_node_installed(item)
@ -122,11 +125,7 @@ async def fetch_customnode_list(request):
else: else:
uri = 'https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json' uri = 'https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json'
async with aiohttp.ClientSession() as session: json_obj = await get_data(uri)
async with session.get(uri) as resp:
json_text = await resp.text()
json_obj = json.loads(json_text)
check_custom_nodes_installed(json_obj) check_custom_nodes_installed(json_obj)
return web.json_response(json_obj, content_type='application/json') return web.json_response(json_obj, content_type='application/json')
@ -179,11 +178,8 @@ async def fetch_externalmodel_list(request):
else: else:
uri = 'https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/model-list.json' uri = 'https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/model-list.json'
async with aiohttp.ClientSession() as session:
async with session.get(uri) as resp:
json_text = await resp.text()
json_obj = json.loads(json_text)
json_obj = await get_data(uri)
check_model_installed(json_obj) check_model_installed(json_obj)
return web.json_response(json_obj, content_type='application/json') return web.json_response(json_obj, content_type='application/json')
@ -234,10 +230,17 @@ def download_url_with_agent(url, save_path):
return True return True
def copy_install(files): def copy_install(files, js_path_name=None):
for url in files: for url in files:
try: try:
if url.endswith(".py"):
download_url(url, custom_nodes_path) download_url(url, custom_nodes_path)
else:
path = os.path.join(js_path, js_path_name) if js_path_name is not None else js_path
if not os.path.exists(path):
os.makedirs(path)
download_url(url, path)
except Exception as e: except Exception as e:
print(f"Install(copy) error: {url} / {e}") print(f"Install(copy) error: {url} / {e}")
return False return False
@ -304,7 +307,8 @@ async def install_custom_node(request):
res = unzip_install(json_data['files']) res = unzip_install(json_data['files'])
if install_type == "copy": if install_type == "copy":
res = copy_install(json_data['files']) js_path_name = json_data['js_path'] if 'js_path' in json_data else None
res = copy_install(json_data['files'], js_path_name)
elif install_type == "git-clone": elif install_type == "git-clone":
res = gitclone_install(json_data['files']) res = gitclone_install(json_data['files'])

View File

@ -360,6 +360,34 @@
"install_type": "copy", "install_type": "copy",
"description": "Custom node for ComfyUI, translate promt from other languages into english" "description": "Custom node for ComfyUI, translate promt from other languages into english"
}, },
{
"author": "pythongosssss",
"title": "ComfyUI-Custom-Scripts",
"reference": "https://github.com/pythongosssss/ComfyUI-Custom-Scripts",
"js_path": "ComfyUI-Custom-Scripts",
"files": [
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/anime-segmentation/anime_segmentation.py",
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/auto-arrange-graph/graphArrange.js",
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/export-workflow-svg/exportAsSvg.js",
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/follow-execution/followExecution.js",
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/image-feed/imageFeed.js",
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/latent-upscale-by/latent_upscale_by.py",
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/lock-nodes-and-groups/locking.js",
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/lora-subfolders/loraSubfolders.js",
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/preset-text/presetText.js",
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/quick-nodes/quickNodes.js",
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/show-text/showText.js",
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/show-text/show_text.py",
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/touch-support/touchEvents.js",
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/wd14-tagger/wd14tagger.js",
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/wd14-tagger/wd14tagger.py",
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/widget-defaults/widgetDefaults.js",
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/workflows/index.js",
"https://github.com/pythongosssss/ComfyUI-Custom-Scripts/raw/main/workflows/workflows.py"
],
"install_type": "copy",
"description": "This extension provides: Auto Arrange Graph, Workflow SVG, Favicon Status, Image Feed, Latent Upscale By, Lock Nodes & Groups, Lora Subfolders, Preset Text, Show Text, Touch Support, WD14 Tagger"
},
{ {
"author": "theally", "author": "theally",
"title": "TheAlly's Custom Nodes", "title": "TheAlly's Custom Nodes",

View File

@ -57,7 +57,8 @@ async function install_custom_node(target, caller) {
return false; return false;
} }
finally { finally {
caller.invalidateControl(); await caller.invalidateControl();
caller.updateMessage('<BR>To apply the installed custom node, please restart ComfyUI.');
} }
} }
} }
@ -84,7 +85,8 @@ async function install_model(target) {
return false; return false;
} }
finally { finally {
ModelInstaller.instance.invalidateControl(); await ModelInstaller.instance.invalidateControl();
ModelInstaller.instance.updateMessage("<BR>To apply the installed model, please click the 'Refresh' button on the main menu.");
} }
} }
} }
@ -110,7 +112,7 @@ class CustomNodesInstaller extends ComfyDialog {
} }
startInstall(target) { startInstall(target) {
this.message_box.innerHTML = `<BR><font color="green">Installing '${target.title}'</font>`; this.updateMessage(`<BR><font color="green">Installing '${target.title}'</font>`);
for(let i in this.install_buttons) { for(let i in this.install_buttons) {
this.install_buttons[i].disabled = true; this.install_buttons[i].disabled = true;
@ -130,6 +132,10 @@ class CustomNodesInstaller extends ComfyDialog {
this.createControls(); this.createControls();
} }
updateMessage(msg) {
this.message_box.innerHTML = msg;
}
async createGrid() { async createGrid() {
var grid = document.createElement('table'); var grid = document.createElement('table');
grid.setAttribute('id', 'custom-nodes-grid'); grid.setAttribute('id', 'custom-nodes-grid');
@ -275,7 +281,7 @@ class AlternativesInstaller extends ComfyDialog {
} }
startInstall(target) { startInstall(target) {
this.message_box.innerHTML = `<BR><font color="green">Installing '${target.title}'</font>`; this.updateMessage(`<BR><font color="green">Installing '${target.title}'</font>`);
for(let i in this.install_buttons) { for(let i in this.install_buttons) {
this.install_buttons[i].disabled = true; this.install_buttons[i].disabled = true;
@ -295,6 +301,10 @@ class AlternativesInstaller extends ComfyDialog {
this.createControls(); this.createControls();
} }
updateMessage(msg) {
this.message_box.innerHTML = msg;
}
async createGrid() { async createGrid() {
var grid = document.createElement('table'); var grid = document.createElement('table');
grid.setAttribute('id', 'alternatives-grid'); grid.setAttribute('id', 'alternatives-grid');
@ -466,7 +476,7 @@ class ModelInstaller extends ComfyDialog {
} }
startInstall(target) { startInstall(target) {
this.message_box.innerHTML = `<BR><font color="green">Installing '${target.name}'</font>`; this.updateMessage(`<BR><font color="green">Installing '${target.name}'</font>`);
for(let i in this.install_buttons) { for(let i in this.install_buttons) {
this.install_buttons[i].disabled = true; this.install_buttons[i].disabled = true;
@ -486,6 +496,10 @@ class ModelInstaller extends ComfyDialog {
this.createControls(); this.createControls();
} }
updateMessage(msg) {
this.message_box.innerHTML = msg;
}
async createGrid(models_json) { async createGrid(models_json) {
var grid = document.createElement('table'); var grid = document.createElement('table');
grid.setAttribute('id', 'external-models-grid'); grid.setAttribute('id', 'external-models-grid');