mirror of
https://git.datalinker.icu/ltdrdata/ComfyUI-Manager
synced 2025-12-08 21:54:26 +08:00
Merge branch 'main' into feat/cnr
This commit is contained in:
commit
222254896c
23
.github/workflows/ruff.yml
vendored
Normal file
23
.github/workflows/ruff.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
name: Python Linting
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
ruff:
|
||||
name: Run Ruff
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.x
|
||||
|
||||
- name: Install Ruff
|
||||
run: pip install ruff
|
||||
|
||||
- name: Run Ruff
|
||||
run: ruff check .
|
||||
@ -5,11 +5,11 @@ cli_mode_flag = os.path.join(os.path.dirname(__file__), '.enable-cli-only-mode')
|
||||
|
||||
if not os.path.exists(cli_mode_flag):
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), "glob"))
|
||||
import manager_server
|
||||
import share_3rdparty
|
||||
import manager_server # noqa: F401
|
||||
import share_3rdparty # noqa: F401
|
||||
WEB_DIRECTORY = "js"
|
||||
else:
|
||||
print(f"\n[ComfyUI-Manager] !! cli-only-mode is enabled !!\n")
|
||||
print("\n[ComfyUI-Manager] !! cli-only-mode is enabled !!\n")
|
||||
|
||||
NODE_CLASS_MAPPINGS = {}
|
||||
__all__ = ['NODE_CLASS_MAPPINGS']
|
||||
|
||||
13
cm-cli.py
13
cm-cli.py
@ -26,7 +26,7 @@ comfyui_manager_path = os.path.abspath(os.path.dirname(__file__))
|
||||
comfy_path = os.environ.get('COMFYUI_PATH')
|
||||
|
||||
if comfy_path is None:
|
||||
print(f"\n[bold yellow]WARN: The `COMFYUI_PATH` environment variable is not set. Assuming `custom_nodes/ComfyUI-Manager/../../` as the ComfyUI path.[/bold yellow]", file=sys.stderr)
|
||||
print("\n[bold yellow]WARN: The `COMFYUI_PATH` environment variable is not set. Assuming `custom_nodes/ComfyUI-Manager/../../` as the ComfyUI path.[/bold yellow]", file=sys.stderr)
|
||||
comfy_path = os.path.abspath(os.path.join(comfyui_manager_path, '..', '..'))
|
||||
|
||||
startup_script_path = os.path.join(comfyui_manager_path, "startup-scripts")
|
||||
@ -50,7 +50,6 @@ def check_comfyui_hash():
|
||||
repo = git.Repo(comfy_path)
|
||||
core.comfy_ui_revision = len(list(repo.iter_commits('HEAD')))
|
||||
|
||||
comfy_ui_hash = repo.head.commit.hexsha
|
||||
cm_global.variables['comfyui.revision'] = core.comfy_ui_revision
|
||||
|
||||
core.comfy_ui_commit_datetime = repo.head.commit.committed_datetime
|
||||
@ -827,13 +826,13 @@ def cli_only_mode(
|
||||
)):
|
||||
cli_mode_flag = os.path.join(os.path.dirname(__file__), '.enable-cli-only-mode')
|
||||
if mode.lower() == 'enable':
|
||||
with open(cli_mode_flag, 'w') as file:
|
||||
with open(cli_mode_flag, 'w'):
|
||||
pass
|
||||
print(f"\nINFO: `cli-only-mode` is enabled\n")
|
||||
print("\nINFO: `cli-only-mode` is enabled\n")
|
||||
elif mode.lower() == 'disable':
|
||||
if os.path.exists(cli_mode_flag):
|
||||
os.remove(cli_mode_flag)
|
||||
print(f"\nINFO: `cli-only-mode` is disabled\n")
|
||||
print("\nINFO: `cli-only-mode` is disabled\n")
|
||||
else:
|
||||
print(f"\n[bold red]Invalid value for cli-only-mode: {mode}[/bold red]\n")
|
||||
exit(1)
|
||||
@ -962,7 +961,7 @@ def restore_dependencies():
|
||||
total = len(node_paths)
|
||||
i = 1
|
||||
for x in node_paths:
|
||||
print(f"----------------------------------------------------------------------------------------------------")
|
||||
print("----------------------------------------------------------------------------------------------------")
|
||||
print(f"Restoring [{i}/{total}]: {x}")
|
||||
unified_manager.execute_install_script('', x, instant_execution=True)
|
||||
i += 1
|
||||
@ -1075,4 +1074,4 @@ if __name__ == '__main__':
|
||||
sys.exit(app())
|
||||
|
||||
|
||||
print(f"")
|
||||
print("")
|
||||
|
||||
@ -48,7 +48,7 @@ nodelist_path = os.path.join(os.path.dirname(__file__), "custom-node-list.json")
|
||||
working_directory = os.getcwd()
|
||||
|
||||
if os.path.basename(working_directory) != 'custom_nodes':
|
||||
print(f"WARN: This script should be executed in custom_nodes dir")
|
||||
print("WARN: This script should be executed in custom_nodes dir")
|
||||
print(f"DBG: INFO {working_directory}")
|
||||
print(f"DBG: INFO {sys.argv}")
|
||||
# exit(-1)
|
||||
|
||||
@ -6,6 +6,7 @@ import re
|
||||
import shutil
|
||||
import configparser
|
||||
import platform
|
||||
from datetime import datetime
|
||||
|
||||
import git
|
||||
from git.remote import RemoteProgress
|
||||
@ -14,6 +15,7 @@ from tqdm.auto import tqdm
|
||||
import time
|
||||
import yaml
|
||||
import zipfile
|
||||
import traceback
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
|
||||
orig_print = print
|
||||
@ -28,8 +30,7 @@ sys.path.append(glob_path)
|
||||
|
||||
import cm_global
|
||||
import cnr_utils
|
||||
from manager_util import *
|
||||
|
||||
import manager_util
|
||||
|
||||
version_code = [3, 0]
|
||||
version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
|
||||
@ -38,7 +39,7 @@ version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' i
|
||||
DEFAULT_CHANNEL = "https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main"
|
||||
|
||||
|
||||
custom_nodes_path = os.path.abspath(os.path.join(comfyui_manager_path, '..'))
|
||||
custom_nodes_path = os.path.abspath(os.path.join(manager_util.comfyui_manager_path, '..'))
|
||||
|
||||
default_custom_nodes_path = None
|
||||
|
||||
@ -128,10 +129,10 @@ if comfy_path is None:
|
||||
except:
|
||||
comfy_path = os.path.abspath(os.path.join(custom_nodes_path, '..'))
|
||||
|
||||
channel_list_path = os.path.join(comfyui_manager_path, 'channels.list')
|
||||
config_path = os.path.join(comfyui_manager_path, "config.ini")
|
||||
startup_script_path = os.path.join(comfyui_manager_path, "startup-scripts")
|
||||
git_script_path = os.path.join(comfyui_manager_path, "git_helper.py")
|
||||
channel_list_path = os.path.join(manager_util.comfyui_manager_path, 'channels.list')
|
||||
config_path = os.path.join(manager_util.comfyui_manager_path, "config.ini")
|
||||
startup_script_path = os.path.join(manager_util.comfyui_manager_path, "startup-scripts")
|
||||
git_script_path = os.path.join(manager_util.comfyui_manager_path, "git_helper.py")
|
||||
cached_config = None
|
||||
js_path = None
|
||||
|
||||
@ -171,8 +172,8 @@ def get_installed_packages():
|
||||
continue
|
||||
|
||||
pip_map[y[0]] = y[1]
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"[ComfyUI-Manager] Failed to retrieve the information of installed pip packages.")
|
||||
except subprocess.CalledProcessError:
|
||||
print("[ComfyUI-Manager] Failed to retrieve the information of installed pip packages.")
|
||||
return set()
|
||||
|
||||
return pip_map
|
||||
@ -203,7 +204,7 @@ def is_blacklisted(name):
|
||||
return True
|
||||
elif match.group(2) in ['<=', '==', '<']:
|
||||
if name in pips:
|
||||
if StrictVersion(pips[name]) >= StrictVersion(match.group(3)):
|
||||
if manager_util.StrictVersion(pips[name]) >= manager_util.StrictVersion(match.group(3)):
|
||||
return True
|
||||
|
||||
return False
|
||||
@ -232,7 +233,7 @@ def is_installed(name):
|
||||
return True
|
||||
elif match.group(2) in ['<=', '==', '<']:
|
||||
if name in pips:
|
||||
if StrictVersion(pips[name]) >= StrictVersion(match.group(3)):
|
||||
if manager_util.StrictVersion(pips[name]) >= manager_util.StrictVersion(match.group(3)):
|
||||
print(f"[ComfyUI-Manager] skip black listed pip installation: '{name}'")
|
||||
return True
|
||||
|
||||
@ -875,7 +876,7 @@ class UnifiedManager:
|
||||
|
||||
archive_name = f"CNR_temp_{str(uuid.uuid4())}.zip" # should be unpredictable name - security precaution
|
||||
download_path = os.path.join(custom_nodes_path, archive_name)
|
||||
download_url(node_info.download_url, custom_nodes_path, archive_name)
|
||||
manager_util.download_url(node_info.download_url, custom_nodes_path, archive_name)
|
||||
|
||||
# 2. extract files into <node_id>@<cur_ver>
|
||||
install_path = self.active_nodes[node_id][1]
|
||||
@ -1138,7 +1139,7 @@ class UnifiedManager:
|
||||
if os.path.exists(install_path):
|
||||
return result.fail(f'Install path already exists: {install_path}')
|
||||
|
||||
download_url(node_info.download_url, custom_nodes_path, archive_name)
|
||||
manager_util.download_url(node_info.download_url, custom_nodes_path, archive_name)
|
||||
os.makedirs(install_path, exist_ok=True)
|
||||
extracted = cnr_utils.extract_package_as_zip(download_path, install_path)
|
||||
os.remove(download_path)
|
||||
@ -1399,7 +1400,7 @@ def get_channel_dict():
|
||||
if not os.path.exists(channel_list_path):
|
||||
shutil.copy(channel_list_path+'.template', channel_list_path)
|
||||
|
||||
with open(os.path.join(comfyui_manager_path, 'channels.list'), 'r') as file:
|
||||
with open(os.path.join(manager_util.comfyui_manager_path, 'channels.list'), 'r') as file:
|
||||
channels = file.read()
|
||||
for x in channels.split('\n'):
|
||||
channel_info = x.split("::")
|
||||
@ -1557,7 +1558,7 @@ def try_install_script(url, repo_path, install_cmd, instant_execution=False):
|
||||
if comfy_ui_commit_datetime.date() < comfy_ui_required_commit_datetime.date():
|
||||
print("\n\n###################################################################")
|
||||
print(f"[WARN] ComfyUI-Manager: Your ComfyUI version ({comfy_ui_revision})[{comfy_ui_commit_datetime.date()}] is too old. Please update to the latest version.")
|
||||
print(f"[WARN] The extension installation feature may not work properly in the current installed ComfyUI version on Windows environment.")
|
||||
print("[WARN] The extension installation feature may not work properly in the current installed ComfyUI version on Windows environment.")
|
||||
print("###################################################################\n\n")
|
||||
except:
|
||||
pass
|
||||
@ -1598,7 +1599,7 @@ def __win_check_git_update(path, do_fetch=False, do_update=False):
|
||||
output, _ = process.communicate()
|
||||
output = output.decode('utf-8').strip()
|
||||
except Exception:
|
||||
print(f'[ComfyUI-Manager] failed to fixing')
|
||||
print('[ComfyUI-Manager] failed to fixing')
|
||||
|
||||
if 'detected dubious' in output:
|
||||
print(f'\n[ComfyUI-Manager] Failed to fixing repository setup. Please execute this command on cmd: \n'
|
||||
@ -1651,7 +1652,7 @@ def execute_install_script(url, repo_path, lazy_mode=False, instant_execution=Fa
|
||||
else:
|
||||
if os.path.exists(requirements_path) and not no_deps:
|
||||
print("Install: pip packages")
|
||||
pip_fixer = PIPFixer(get_installed_packages())
|
||||
pip_fixer = manager_util.PIPFixer(get_installed_packages())
|
||||
with open(requirements_path, "r") as requirements_file:
|
||||
for line in requirements_file:
|
||||
#handle comments
|
||||
@ -1677,7 +1678,7 @@ def execute_install_script(url, repo_path, lazy_mode=False, instant_execution=Fa
|
||||
pip_fixer.fix_broken()
|
||||
|
||||
if os.path.exists(install_script_path):
|
||||
print(f"Install: install script")
|
||||
print("Install: install script")
|
||||
install_cmd = [sys.executable, "install.py"]
|
||||
try_install_script(url, repo_path, install_cmd, instant_execution=instant_execution)
|
||||
|
||||
@ -1918,34 +1919,34 @@ async def get_data_by_mode(mode, filename, channel_url=None):
|
||||
|
||||
try:
|
||||
if mode == "local":
|
||||
uri = os.path.join(comfyui_manager_path, filename)
|
||||
json_obj = await get_data(uri)
|
||||
uri = os.path.join(manager_util.comfyui_manager_path, filename)
|
||||
json_obj = await manager_util.get_data(uri)
|
||||
else:
|
||||
if channel_url is None:
|
||||
uri = get_config()['channel_url'] + '/' + filename
|
||||
else:
|
||||
uri = channel_url + '/' + filename
|
||||
|
||||
cache_uri = str(simple_hash(uri))+'_'+filename
|
||||
cache_uri = os.path.join(cache_dir, cache_uri)
|
||||
cache_uri = str(manager_util.simple_hash(uri))+'_'+filename
|
||||
cache_uri = os.path.join(manager_util.cache_dir, cache_uri)
|
||||
|
||||
if mode == "cache":
|
||||
if is_file_created_within_one_day(cache_uri):
|
||||
json_obj = await get_data(cache_uri)
|
||||
if manager_util.is_file_created_within_one_day(cache_uri):
|
||||
json_obj = await manager_util.get_data(cache_uri)
|
||||
else:
|
||||
json_obj = await get_data(uri)
|
||||
with cache_lock:
|
||||
json_obj = await manager_util.get_data(uri)
|
||||
with manager_util.cache_lock:
|
||||
with open(cache_uri, "w", encoding='utf-8') as file:
|
||||
json.dump(json_obj, file, indent=4, sort_keys=True)
|
||||
else:
|
||||
json_obj = await get_data(uri)
|
||||
with cache_lock:
|
||||
json_obj = await manager_util.get_data(uri)
|
||||
with manager_util.cache_lock:
|
||||
with open(cache_uri, "w", encoding='utf-8') as file:
|
||||
json.dump(json_obj, file, indent=4, sort_keys=True)
|
||||
except Exception as e:
|
||||
print(f"[ComfyUI-Manager] Due to a network error, switching to local mode.\n=> {filename}\n=> {e}")
|
||||
uri = os.path.join(comfyui_manager_path, filename)
|
||||
json_obj = await get_data(uri)
|
||||
uri = os.path.join(manager_util.comfyui_manager_path, filename)
|
||||
json_obj = await manager_util.get_data(uri)
|
||||
|
||||
return json_obj
|
||||
|
||||
@ -2169,7 +2170,7 @@ def update_path(repo_path, instant_execution=False, no_deps=False):
|
||||
remote.fetch()
|
||||
except Exception as e:
|
||||
if 'detected dubious' in str(e):
|
||||
print(f"[ComfyUI-Manager] Try fixing 'dubious repository' error on 'ComfyUI' repository")
|
||||
print("[ComfyUI-Manager] Try fixing 'dubious repository' error on 'ComfyUI' repository")
|
||||
safedir_path = comfy_path.replace('\\', '/')
|
||||
subprocess.run(['git', 'config', '--global', '--add', 'safe.directory', safedir_path])
|
||||
try:
|
||||
@ -2263,7 +2264,7 @@ def get_current_snapshot():
|
||||
repo_path = comfy_path
|
||||
|
||||
if not os.path.exists(os.path.join(repo_path, '.git')):
|
||||
print(f"ComfyUI update fail: The installed ComfyUI does not have a Git repository.")
|
||||
print("ComfyUI update fail: The installed ComfyUI does not have a Git repository.")
|
||||
return {}
|
||||
|
||||
repo = git.Repo(repo_path)
|
||||
@ -2340,7 +2341,7 @@ def save_snapshot_with_postfix(postfix, path=None):
|
||||
date_time_format = now.strftime("%Y-%m-%d_%H-%M-%S")
|
||||
file_name = f"{date_time_format}_{postfix}"
|
||||
|
||||
path = os.path.join(comfyui_manager_path, 'snapshots', f"{file_name}.json")
|
||||
path = os.path.join(manager_util.comfyui_manager_path, 'snapshots', f"{file_name}.json")
|
||||
else:
|
||||
file_name = path.replace('\\', '/').split('/')[-1]
|
||||
file_name = file_name.split('.')[-2]
|
||||
|
||||
@ -11,6 +11,7 @@ import threading
|
||||
import re
|
||||
import shutil
|
||||
import git
|
||||
from datetime import datetime
|
||||
|
||||
from server import PromptServer
|
||||
import manager_core as core
|
||||
@ -23,9 +24,9 @@ print(f"### Loading: ComfyUI-Manager ({core.version_str})")
|
||||
comfy_ui_hash = "-"
|
||||
comfyui_tag = None
|
||||
|
||||
SECURITY_MESSAGE_MIDDLE_OR_BELOW = f"ERROR: To use this action, a security_level of `middle or below` is required. Please contact the administrator.\nReference: https://github.com/ltdrdata/ComfyUI-Manager#security-policy"
|
||||
SECURITY_MESSAGE_NORMAL_MINUS = f"ERROR: To use this feature, you must either set '--listen' to a local IP and set the security level to 'normal-' or lower, or set the security level to 'middle' or 'weak'. Please contact the administrator.\nReference: https://github.com/ltdrdata/ComfyUI-Manager#security-policy"
|
||||
SECURITY_MESSAGE_GENERAL = f"ERROR: This installation is not allowed in this security_level. Please contact the administrator.\nReference: https://github.com/ltdrdata/ComfyUI-Manager#security-policy"
|
||||
SECURITY_MESSAGE_MIDDLE_OR_BELOW = "ERROR: To use this action, a security_level of `middle or below` is required. Please contact the administrator.\nReference: https://github.com/ltdrdata/ComfyUI-Manager#security-policy"
|
||||
SECURITY_MESSAGE_NORMAL_MINUS = "ERROR: To use this feature, you must either set '--listen' to a local IP and set the security level to 'normal-' or lower, or set the security level to 'middle' or 'weak'. Please contact the administrator.\nReference: https://github.com/ltdrdata/ComfyUI-Manager#security-policy"
|
||||
SECURITY_MESSAGE_GENERAL = "ERROR: This installation is not allowed in this security_level. Please contact the administrator.\nReference: https://github.com/ltdrdata/ComfyUI-Manager#security-policy"
|
||||
|
||||
routes = PromptServer.instance.routes
|
||||
|
||||
@ -129,11 +130,11 @@ from manager_downloader import download_url
|
||||
core.comfy_path = os.path.dirname(folder_paths.__file__)
|
||||
core.js_path = os.path.join(core.comfy_path, "web", "extensions")
|
||||
|
||||
local_db_model = os.path.join(core.comfyui_manager_path, "model-list.json")
|
||||
local_db_alter = os.path.join(core.comfyui_manager_path, "alter-list.json")
|
||||
local_db_custom_node_list = os.path.join(core.comfyui_manager_path, "custom-node-list.json")
|
||||
local_db_extension_node_mappings = os.path.join(core.comfyui_manager_path, "extension-node-map.json")
|
||||
components_path = os.path.join(core.comfyui_manager_path, 'components')
|
||||
local_db_model = os.path.join(manager_util.comfyui_manager_path, "model-list.json")
|
||||
local_db_alter = os.path.join(manager_util.comfyui_manager_path, "alter-list.json")
|
||||
local_db_custom_node_list = os.path.join(manager_util.comfyui_manager_path, "custom-node-list.json")
|
||||
local_db_extension_node_mappings = os.path.join(manager_util.comfyui_manager_path, "extension-node-map.json")
|
||||
components_path = os.path.join(manager_util.comfyui_manager_path, 'components')
|
||||
|
||||
|
||||
def set_preview_method(method):
|
||||
@ -208,7 +209,7 @@ def print_comfyui_version():
|
||||
|
||||
del cm_global.variables['cm.on_revision_detected_handler']
|
||||
else:
|
||||
print(f"[ComfyUI-Manager] Some features are restricted due to your ComfyUI being outdated.")
|
||||
print("[ComfyUI-Manager] Some features are restricted due to your ComfyUI being outdated.")
|
||||
# <--
|
||||
|
||||
if current_branch == "master":
|
||||
@ -241,7 +242,6 @@ setup_environment()
|
||||
|
||||
# Expand Server api
|
||||
|
||||
import server
|
||||
from aiohttp import web
|
||||
import aiohttp
|
||||
import json
|
||||
@ -287,7 +287,7 @@ def get_model_dir(data):
|
||||
if folder_paths.folder_names_and_paths.get("text_encoders"):
|
||||
base_model = folder_paths.folder_names_and_paths["text_encoders"][0][0]
|
||||
else:
|
||||
print(f"[ComfyUI-Manager] Your ComfyUI is outdated version.")
|
||||
print("[ComfyUI-Manager] Your ComfyUI is outdated version.")
|
||||
base_model = folder_paths.folder_names_and_paths["clip"][0][0] # outdated version
|
||||
elif model_type == "VAE":
|
||||
base_model = folder_paths.folder_names_and_paths["vae"][0][0]
|
||||
@ -311,7 +311,7 @@ def get_model_dir(data):
|
||||
if folder_paths.folder_names_and_paths.get("diffusion_models"):
|
||||
base_model = folder_paths.folder_names_and_paths["diffusion_models"][0][1]
|
||||
else:
|
||||
print(f"[ComfyUI-Manager] Your ComfyUI is outdated version.")
|
||||
print("[ComfyUI-Manager] Your ComfyUI is outdated version.")
|
||||
base_model = folder_paths.folder_names_and_paths["unet"][0][0] # outdated version
|
||||
else:
|
||||
base_model = os.path.join(models_base, "etc")
|
||||
@ -344,15 +344,15 @@ def check_state_of_git_node_pack(node_packs, do_fetch=False, do_update_check=Tru
|
||||
executor.submit(process_custom_node, v)
|
||||
|
||||
if do_fetch:
|
||||
print(f"\x1b[2K\rFetching done.")
|
||||
print("\x1b[2K\rFetching done.")
|
||||
elif do_update:
|
||||
update_exists = any(item.get('updatable', False) for item in node_packs.values())
|
||||
if update_exists:
|
||||
print(f"\x1b[2K\rUpdate done.")
|
||||
print("\x1b[2K\rUpdate done.")
|
||||
else:
|
||||
print(f"\x1b[2K\rAll extensions are already up-to-date.")
|
||||
print("\x1b[2K\rAll extensions are already up-to-date.")
|
||||
elif do_update_check:
|
||||
print(f"\x1b[2K\rUpdate check done.")
|
||||
print("\x1b[2K\rUpdate check done.")
|
||||
|
||||
|
||||
def nickname_filter(json_obj):
|
||||
@ -652,7 +652,7 @@ async def remove_snapshot(request):
|
||||
|
||||
|
||||
@routes.get("/snapshot/restore")
|
||||
async def remove_snapshot(request):
|
||||
async def restore_snapshot(request):
|
||||
if not is_allowed_security_level('middle'):
|
||||
print(SECURITY_MESSAGE_MIDDLE_OR_BELOW)
|
||||
return web.Response(status=403)
|
||||
@ -948,7 +948,7 @@ async def install_custom_node_git_url(request):
|
||||
|
||||
|
||||
@routes.post("/customnode/install/pip")
|
||||
async def install_custom_node_git_url(request):
|
||||
async def install_custom_node_pip(request):
|
||||
if not is_allowed_security_level('high'):
|
||||
print(SECURITY_MESSAGE_NORMAL_MINUS)
|
||||
return web.Response(status=403)
|
||||
@ -1015,13 +1015,13 @@ async def update_custom_node(request):
|
||||
|
||||
@routes.get("/comfyui_manager/update_comfyui")
|
||||
async def update_comfyui(request):
|
||||
print(f"Update ComfyUI")
|
||||
print("Update ComfyUI")
|
||||
|
||||
try:
|
||||
repo_path = os.path.dirname(folder_paths.__file__)
|
||||
res = core.update_path(repo_path)
|
||||
if res == "fail":
|
||||
print(f"ComfyUI update fail: The installed ComfyUI does not have a Git repository.")
|
||||
print("ComfyUI update fail: The installed ComfyUI does not have a Git repository.")
|
||||
return web.Response(status=400)
|
||||
elif res == "updated":
|
||||
return web.Response(status=201)
|
||||
@ -1268,9 +1268,9 @@ async def get_notice(request):
|
||||
|
||||
try:
|
||||
if core.comfy_ui_commit_datetime == datetime(1900, 1, 1, 0, 0, 0):
|
||||
markdown_content = f'<P style="text-align: center; color:red; background-color:white; font-weight:bold">Your ComfyUI isn\'t git repo.</P>' + markdown_content
|
||||
markdown_content = '<P style="text-align: center; color:red; background-color:white; font-weight:bold">Your ComfyUI isn\'t git repo.</P>' + markdown_content
|
||||
elif core.comfy_ui_required_commit_datetime.date() > core.comfy_ui_commit_datetime.date():
|
||||
markdown_content = f'<P style="text-align: center; color:red; background-color:white; font-weight:bold">Your ComfyUI is too OUTDATED!!!</P>' + markdown_content
|
||||
markdown_content = '<P style="text-align: center; color:red; background-color:white; font-weight:bold">Your ComfyUI is too OUTDATED!!!</P>' + markdown_content
|
||||
except:
|
||||
pass
|
||||
|
||||
@ -1289,17 +1289,17 @@ def restart(self):
|
||||
|
||||
try:
|
||||
sys.stdout.close_log()
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if '__COMFY_CLI_SESSION__' in os.environ:
|
||||
with open(os.path.join(os.environ['__COMFY_CLI_SESSION__'] + '.reboot'), 'w') as file:
|
||||
with open(os.path.join(os.environ['__COMFY_CLI_SESSION__'] + '.reboot'), 'w'):
|
||||
pass
|
||||
|
||||
print(f"\nRestarting...\n\n")
|
||||
print("\nRestarting...\n\n")
|
||||
exit(0)
|
||||
|
||||
print(f"\nRestarting... [Legacy Mode]\n\n")
|
||||
print("\nRestarting... [Legacy Mode]\n\n")
|
||||
|
||||
sys_argv = sys.argv.copy()
|
||||
if '--windows-standalone-build' in sys_argv:
|
||||
@ -1399,11 +1399,11 @@ async def default_cache_update():
|
||||
async def get_cache(filename):
|
||||
uri = f"{core.DEFAULT_CHANNEL}/{filename}"
|
||||
cache_uri = str(manager_util.simple_hash(uri)) + '_' + filename
|
||||
cache_uri = os.path.join(core.cache_dir, cache_uri)
|
||||
cache_uri = os.path.join(manager_util.cache_dir, cache_uri)
|
||||
|
||||
json_obj = await manager_util.get_data(uri, True)
|
||||
|
||||
with core.cache_lock:
|
||||
with manager_util.cache_lock:
|
||||
with open(cache_uri, "w", encoding='utf-8') as file:
|
||||
json.dump(json_obj, file, indent=4, sort_keys=True)
|
||||
print(f"[ComfyUI-Manager] default cache updated: {uri}")
|
||||
|
||||
@ -192,8 +192,8 @@ def get_installed_packages(renew=False):
|
||||
continue
|
||||
|
||||
pip_map[y[0]] = y[1]
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"[ComfyUI-Manager] Failed to retrieve the information of installed pip packages.")
|
||||
except subprocess.CalledProcessError:
|
||||
print("[ComfyUI-Manager] Failed to retrieve the information of installed pip packages.")
|
||||
return set()
|
||||
|
||||
return pip_map
|
||||
@ -262,9 +262,9 @@ class PIPFixer:
|
||||
cmd = [sys.executable, '-m', 'pip', 'uninstall', 'comfy']
|
||||
subprocess.check_output(cmd, universal_newlines=True)
|
||||
|
||||
print(f"[manager-core] 'comfy' python package is uninstalled.\nWARN: The 'comfy' package is completely unrelated to ComfyUI and should never be installed as it causes conflicts with ComfyUI.")
|
||||
print("[manager-core] 'comfy' python package is uninstalled.\nWARN: The 'comfy' package is completely unrelated to ComfyUI and should never be installed as it causes conflicts with ComfyUI.")
|
||||
except Exception as e:
|
||||
print(f"[manager-core] Failed to uninstall `comfy` python package")
|
||||
print("[manager-core] Failed to uninstall `comfy` python package")
|
||||
print(e)
|
||||
|
||||
# fix torch - reinstall torch packages if version is changed
|
||||
@ -274,7 +274,7 @@ class PIPFixer:
|
||||
or self.prev_pip_versions['torchaudio'] != new_pip_versions['torchaudio']:
|
||||
self.torch_rollback()
|
||||
except Exception as e:
|
||||
print(f"[manager-core] Failed to restore PyTorch")
|
||||
print("[manager-core] Failed to restore PyTorch")
|
||||
print(e)
|
||||
|
||||
# fix opencv
|
||||
@ -308,7 +308,7 @@ class PIPFixer:
|
||||
|
||||
print(f"[manager-core] 'opencv' dependencies were fixed: {targets}")
|
||||
except Exception as e:
|
||||
print(f"[manager-core] Failed to restore opencv")
|
||||
print("[manager-core] Failed to restore opencv")
|
||||
print(e)
|
||||
|
||||
# fix numpy
|
||||
@ -316,7 +316,7 @@ class PIPFixer:
|
||||
np = new_pip_versions.get('numpy')
|
||||
if np is not None:
|
||||
if StrictVersion(np) >= StrictVersion('2'):
|
||||
subprocess.check_output([sys.executable, '-m', 'pip', 'install', f"numpy<2"], universal_newlines=True)
|
||||
subprocess.check_output([sys.executable, '-m', 'pip', 'install', "numpy<2"], universal_newlines=True)
|
||||
except Exception as e:
|
||||
print(f"[manager-core] Failed to restore numpy")
|
||||
print("[manager-core] Failed to restore numpy")
|
||||
print(e)
|
||||
|
||||
@ -109,7 +109,7 @@ https://blog.comfy.org/comfyui-statement-on-the-ultralytics-crypto-miner-situati
|
||||
|
||||
for x in detected:
|
||||
print(f"\n======== TARGET: {x} =========")
|
||||
print(f"\nTODO:")
|
||||
print("\nTODO:")
|
||||
print(guide.get(x))
|
||||
|
||||
exit(-1)
|
||||
|
||||
@ -178,8 +178,6 @@ async def api_get_comfyworkflows_auth(request):
|
||||
@PromptServer.instance.routes.post("/manager/set_esheep_workflow_and_images")
|
||||
async def set_esheep_workflow_and_images(request):
|
||||
json_data = await request.json()
|
||||
current_workflow = json_data['workflow']
|
||||
images = json_data['images']
|
||||
with open(os.path.join(core.comfyui_manager_path, "esheep_share_message.json"), "w", encoding='utf-8') as file:
|
||||
json.dump(json_data, file, indent=4)
|
||||
return web.Response(status=200)
|
||||
@ -368,9 +366,9 @@ async def share_art(request):
|
||||
text_content += f"{description}\n"
|
||||
if credits:
|
||||
text_content += f"\ncredits: {credits}\n"
|
||||
response = matrix.send_message(comfyui_share_room_id, text_content)
|
||||
response = matrix.send_content(comfyui_share_room_id, mxc_url, filename, 'm.image')
|
||||
response = matrix.send_content(comfyui_share_room_id, workflow_json_mxc_url, 'workflow.json', 'm.file')
|
||||
matrix.send_message(comfyui_share_room_id, text_content)
|
||||
matrix.send_content(comfyui_share_room_id, mxc_url, filename, 'm.image')
|
||||
matrix.send_content(comfyui_share_room_id, workflow_json_mxc_url, 'workflow.json', 'm.file')
|
||||
except:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
@ -14,8 +14,9 @@ glob_path = os.path.join(os.path.dirname(__file__), "glob")
|
||||
sys.path.append(glob_path)
|
||||
|
||||
import security_check
|
||||
from manager_util import *
|
||||
import manager_util
|
||||
import cm_global
|
||||
from datetime import datetime
|
||||
|
||||
security_check.security_check()
|
||||
|
||||
@ -309,27 +310,26 @@ except Exception as e:
|
||||
|
||||
|
||||
try:
|
||||
import git
|
||||
import git # noqa: F401
|
||||
except ModuleNotFoundError:
|
||||
my_path = os.path.dirname(__file__)
|
||||
requirements_path = os.path.join(my_path, "requirements.txt")
|
||||
|
||||
print(f"## ComfyUI-Manager: installing dependencies. (GitPython)")
|
||||
print("## ComfyUI-Manager: installing dependencies. (GitPython)")
|
||||
try:
|
||||
result = subprocess.check_output([sys.executable, '-s', '-m', 'pip', 'install', '-r', requirements_path])
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"## [ERROR] ComfyUI-Manager: Attempting to reinstall dependencies using an alternative method.")
|
||||
except subprocess.CalledProcessError:
|
||||
print("## [ERROR] ComfyUI-Manager: Attempting to reinstall dependencies using an alternative method.")
|
||||
try:
|
||||
result = subprocess.check_output([sys.executable, '-s', '-m', 'pip', 'install', '--user', '-r', requirements_path])
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"## [ERROR] ComfyUI-Manager: Failed to install the GitPython package in the correct Python environment. Please install it manually in the appropriate environment. (You can seek help at https://app.element.io/#/room/%23comfyui_space%3Amatrix.org)")
|
||||
except subprocess.CalledProcessError:
|
||||
print("## [ERROR] ComfyUI-Manager: Failed to install the GitPython package in the correct Python environment. Please install it manually in the appropriate environment. (You can seek help at https://app.element.io/#/room/%23comfyui_space%3Amatrix.org)")
|
||||
|
||||
try:
|
||||
import git
|
||||
print(f"## ComfyUI-Manager: installing dependencies done.")
|
||||
print("## ComfyUI-Manager: installing dependencies done.")
|
||||
except:
|
||||
# maybe we should sys.exit() here? there is at least two screens worth of error messages still being pumped after our error messages
|
||||
print(f"## [ERROR] ComfyUI-Manager: GitPython package seems to be installed, but failed to load somehow. Make sure you have a working git client installed")
|
||||
print("## [ERROR] ComfyUI-Manager: GitPython package seems to be installed, but failed to load somehow. Make sure you have a working git client installed")
|
||||
|
||||
|
||||
print("** ComfyUI startup time:", datetime.now())
|
||||
@ -374,7 +374,7 @@ def check_bypass_ssl():
|
||||
default_conf = config['default']
|
||||
|
||||
if 'bypass_ssl' in default_conf and default_conf['bypass_ssl'].lower() == 'true':
|
||||
print(f"[ComfyUI-Manager] WARN: Unsafe - SSL verification bypass option is Enabled. (see ComfyUI-Manager/config.ini)")
|
||||
print("[ComfyUI-Manager] WARN: Unsafe - SSL verification bypass option is Enabled. (see ComfyUI-Manager/config.ini)")
|
||||
ssl._create_default_https_context = ssl._create_unverified_context # SSL certificate error fix.
|
||||
except Exception:
|
||||
pass
|
||||
@ -386,7 +386,7 @@ check_bypass_ssl()
|
||||
# Perform install
|
||||
processed_install = set()
|
||||
script_list_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "startup-scripts", "install-scripts.txt")
|
||||
pip_fixer = PIPFixer(get_installed_packages())
|
||||
pip_fixer = manager_util.PIPFixer(manager_util.get_installed_packages())
|
||||
|
||||
|
||||
def is_installed(name):
|
||||
@ -405,18 +405,18 @@ def is_installed(name):
|
||||
return True
|
||||
|
||||
if name in cm_global.pip_downgrade_blacklist:
|
||||
pips = get_installed_packages()
|
||||
pips = manager_util.get_installed_packages()
|
||||
|
||||
if match is None:
|
||||
if name in pips:
|
||||
return True
|
||||
elif match.group(2) in ['<=', '==', '<']:
|
||||
if name in pips:
|
||||
if StrictVersion(pips[name]) >= StrictVersion(match.group(3)):
|
||||
if manager_util.StrictVersion(pips[name]) >= manager_util.StrictVersion(match.group(3)):
|
||||
print(f"[ComfyUI-Manager] skip black listed pip installation: '{name}'")
|
||||
return True
|
||||
|
||||
pkg = get_installed_packages().get(name.lower())
|
||||
pkg = manager_util.get_installed_packages().get(name.lower())
|
||||
if pkg is None:
|
||||
return False # update if not installed
|
||||
|
||||
@ -424,9 +424,9 @@ def is_installed(name):
|
||||
return True # don't update if version is not specified
|
||||
|
||||
if match.group(2) in ['>', '>=']:
|
||||
if StrictVersion(pkg) < StrictVersion(match.group(3)):
|
||||
if manager_util.StrictVersion(pkg) < manager_util.StrictVersion(match.group(3)):
|
||||
return False
|
||||
elif StrictVersion(pkg) > StrictVersion(match.group(3)):
|
||||
elif manager_util.StrictVersion(pkg) > manager_util.StrictVersion(match.group(3)):
|
||||
print(f"[SKIP] Downgrading pip package isn't allowed: {name.lower()} (cur={pkg})")
|
||||
|
||||
return True # prevent downgrade
|
||||
@ -465,13 +465,13 @@ if os.path.exists(restore_snapshot_path):
|
||||
exit_code = process_wrap(cmd_str, custom_nodes_path, handler=msg_capture, env=new_env)
|
||||
|
||||
if exit_code != 0:
|
||||
print(f"[ComfyUI-Manager] Restore snapshot failed.")
|
||||
print("[ComfyUI-Manager] Restore snapshot failed.")
|
||||
else:
|
||||
print(f"[ComfyUI-Manager] Restore snapshot done.")
|
||||
print("[ComfyUI-Manager] Restore snapshot done.")
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print(f"[ComfyUI-Manager] Restore snapshot failed.")
|
||||
print("[ComfyUI-Manager] Restore snapshot failed.")
|
||||
|
||||
os.remove(restore_snapshot_path)
|
||||
|
||||
@ -513,10 +513,10 @@ def execute_lazy_cnr_switch(target, zip_url, from_path, to_path, no_deps, custom
|
||||
# 1. download
|
||||
archive_name = f"CNR_temp_{str(uuid.uuid4())}.zip" # should be unpredictable name - security precaution
|
||||
download_path = os.path.join(custom_nodes_path, archive_name)
|
||||
download_url(zip_url, custom_nodes_path, archive_name)
|
||||
manager_util.download_url(zip_url, custom_nodes_path, archive_name)
|
||||
|
||||
# 2. extract files into <node_id>@<cur_ver>
|
||||
extracted = extract_package_as_zip(download_path, from_path)
|
||||
extracted = manager_util.extract_package_as_zip(download_path, from_path)
|
||||
os.remove(download_path)
|
||||
|
||||
if extracted is None:
|
||||
@ -626,7 +626,7 @@ pip_fixer.fix_broken()
|
||||
|
||||
del processed_install
|
||||
del pip_fixer
|
||||
clear_pip_cache()
|
||||
manager_util.clear_pip_cache()
|
||||
|
||||
|
||||
def check_windows_event_loop_policy():
|
||||
@ -642,7 +642,7 @@ def check_windows_event_loop_policy():
|
||||
import asyncio
|
||||
import asyncio.windows_events
|
||||
asyncio.set_event_loop_policy(asyncio.windows_events.WindowsSelectorEventLoopPolicy())
|
||||
print(f"[ComfyUI-Manager] Windows event loop policy mode enabled")
|
||||
print("[ComfyUI-Manager] Windows event loop policy mode enabled")
|
||||
except Exception as e:
|
||||
print(f"[ComfyUI-Manager] WARN: Windows initialization fail: {e}")
|
||||
except Exception:
|
||||
|
||||
12
ruff.toml
Normal file
12
ruff.toml
Normal file
@ -0,0 +1,12 @@
|
||||
# Disable all rules by default
|
||||
lint.ignore = ["ALL"]
|
||||
|
||||
# Enable specific rules
|
||||
lint.select = [
|
||||
"S307", # suspicious-eval-usage
|
||||
# The "F" series in Ruff stands for "Pyflakes" rules, which catch various Python syntax errors and undefined names.
|
||||
# See all rules here: https://docs.astral.sh/ruff/rules/#pyflakes-f
|
||||
"F",
|
||||
]
|
||||
|
||||
exclude = ["*.ipynb"]
|
||||
@ -69,7 +69,7 @@ def extract_nodes(code_text):
|
||||
|
||||
try:
|
||||
if parse_cnt % 100 == 0:
|
||||
print(f".", end="", flush=True)
|
||||
print(".", end="", flush=True)
|
||||
parse_cnt += 1
|
||||
|
||||
code_text = re.sub(r'\\[^"\']', '', code_text)
|
||||
@ -515,7 +515,7 @@ def gen_json(node_info):
|
||||
nodes.sort()
|
||||
data[git_url] = (nodes, metadata_in_url)
|
||||
|
||||
json_path = f"extension-node-map.json"
|
||||
json_path = "extension-node-map.json"
|
||||
with open(json_path, "w", encoding='utf-8') as file:
|
||||
json.dump(data, file, indent=4, sort_keys=True)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user