From 14298b0859619c393c962ab5035720e77cbfa514 Mon Sep 17 00:00:00 2001 From: bymyself Date: Tue, 17 Jun 2025 13:08:52 -0700 Subject: [PATCH] [fix] Remove unused imports to fix linting errors --- comfyui_manager/glob/constants.py | 4 ---- comfyui_manager/glob/utils/security_utils.py | 23 ++++++++++---------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/comfyui_manager/glob/constants.py b/comfyui_manager/glob/constants.py index 727e3f3e..87d28cb6 100644 --- a/comfyui_manager/glob/constants.py +++ b/comfyui_manager/glob/constants.py @@ -1,4 +1,3 @@ -from comfy.cli_args import args 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" @@ -15,9 +14,6 @@ def is_loopback(address): return False -is_local_mode = is_loopback(args.listen) - - model_dir_name_map = { "checkpoints": "checkpoints", "checkpoint": "checkpoints", diff --git a/comfyui_manager/glob/utils/security_utils.py b/comfyui_manager/glob/utils/security_utils.py index 1d465902..91964ff4 100644 --- a/comfyui_manager/glob/utils/security_utils.py +++ b/comfyui_manager/glob/utils/security_utils.py @@ -1,5 +1,6 @@ from comfyui_manager.glob import manager_core as core from comfy.cli_args import args +from comfyui_manager.data_models import SecurityLevel, RiskLevel, ManagerDatabaseSource def is_loopback(address): @@ -13,23 +14,23 @@ def is_loopback(address): def is_allowed_security_level(level): is_local_mode = is_loopback(args.listen) - if level == "block": + if level == RiskLevel.block.value: return False - elif level == "high": + elif level == RiskLevel.high.value: if is_local_mode: - return core.get_config()["security_level"] in ["weak", "normal-"] + return core.get_config()["security_level"] in [SecurityLevel.weak.value, SecurityLevel.normal_.value] else: - return core.get_config()["security_level"] == "weak" - elif level == "middle": - return core.get_config()["security_level"] in ["weak", "normal", "normal-"] + return core.get_config()["security_level"] == SecurityLevel.weak.value + elif level == RiskLevel.middle.value: + return core.get_config()["security_level"] in [SecurityLevel.weak.value, SecurityLevel.normal.value, SecurityLevel.normal_.value] else: return True async def get_risky_level(files, pip_packages): - json_data1 = await core.get_data_by_mode("local", "custom-node-list.json") + json_data1 = await core.get_data_by_mode(ManagerDatabaseSource.local.value, "custom-node-list.json") json_data2 = await core.get_data_by_mode( - "cache", + ManagerDatabaseSource.cache.value, "custom-node-list.json", channel_url="https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main", ) @@ -40,7 +41,7 @@ async def get_risky_level(files, pip_packages): for x in files: if x not in all_urls: - return "high" + return RiskLevel.high.value all_pip_packages = set() for x in json_data1["custom_nodes"] + json_data2["custom_nodes"]: @@ -48,6 +49,6 @@ async def get_risky_level(files, pip_packages): for p in pip_packages: if p not in all_pip_packages: - return "block" + return RiskLevel.block.value - return "middle" + return RiskLevel.middle.value