diff --git a/comfyui_manager/cm-cli.py b/comfyui_manager/cm-cli.py index 8a3f49ed..8dce67b9 100644 --- a/comfyui_manager/cm-cli.py +++ b/comfyui_manager/cm-cli.py @@ -69,7 +69,7 @@ def check_comfyui_hash(): repo = git.Repo(comfy_path) core.comfy_ui_revision = len(list(repo.iter_commits('HEAD'))) core.comfy_ui_commit_datetime = repo.head.commit.committed_datetime - except: + except Exception: print('[bold yellow]INFO: Frozen ComfyUI mode.[/bold yellow]') core.comfy_ui_revision = 0 core.comfy_ui_commit_datetime = 0 @@ -93,7 +93,7 @@ def read_downgrade_blacklist(): items = [x.strip() for x in items if x != ''] cm_global.pip_downgrade_blacklist += items cm_global.pip_downgrade_blacklist = list(set(cm_global.pip_downgrade_blacklist)) - except: + except Exception: pass @@ -1225,7 +1225,7 @@ def install_deps( with open(deps, 'r', encoding="UTF-8", errors="ignore") as json_file: try: json_obj = json.load(json_file) - except: + except Exception: print(f"[bold red]Invalid json file: {deps}[/bold red]") exit(1) diff --git a/comfyui_manager/common/cnr_utils.py b/comfyui_manager/common/cnr_utils.py index 10fad45d..c402707c 100644 --- a/comfyui_manager/common/cnr_utils.py +++ b/comfyui_manager/common/cnr_utils.py @@ -112,7 +112,7 @@ async def _get_cnr_data(cache_mode=True, dont_wait=True): json_obj = await fetch_all() manager_util.save_to_cache(uri, json_obj) return json_obj['nodes'] - except: + except Exception: res = {} print("Cannot connect to comfyregistry.") finally: @@ -237,7 +237,7 @@ def generate_cnr_id(fullpath, cnr_id): if not os.path.exists(cnr_id_path): with open(cnr_id_path, "w") as f: return f.write(cnr_id) - except: + except Exception: print(f"[ComfyUI Manager] unable to create file: {cnr_id_path}") @@ -247,7 +247,7 @@ def read_cnr_id(fullpath): if os.path.exists(cnr_id_path): with open(cnr_id_path) as f: return f.read().strip() - except: + except Exception: pass return None diff --git a/comfyui_manager/common/context.py b/comfyui_manager/common/context.py index 1d190814..1fb92140 100644 --- a/comfyui_manager/common/context.py +++ b/comfyui_manager/common/context.py @@ -14,7 +14,7 @@ if comfy_path is None: try: comfy_path = os.path.abspath(os.path.dirname(sys.modules['__main__'].__file__)) os.environ['COMFYUI_PATH'] = comfy_path - except: + except Exception: logging.error("[ComfyUI-Manager] environment variable 'COMFYUI_PATH' is not specified.") exit(-1) @@ -95,7 +95,7 @@ def get_current_comfyui_ver(): project = data.get('project', {}) return project.get('version') - except: + except Exception: return None @@ -103,7 +103,7 @@ def get_comfyui_tag(): try: with git.Repo(comfy_path) as repo: return repo.git.describe('--tags') - except: + except Exception: return None diff --git a/comfyui_manager/common/git_helper.py b/comfyui_manager/common/git_helper.py index 54031dd1..5fc51478 100644 --- a/comfyui_manager/common/git_helper.py +++ b/comfyui_manager/common/git_helper.py @@ -156,27 +156,27 @@ def switch_to_default_branch(repo): default_branch = repo.git.symbolic_ref(f'refs/remotes/{remote_name}/HEAD').replace(f'refs/remotes/{remote_name}/', '') repo.git.checkout(default_branch) return True - except: + except Exception: # try checkout master # try checkout main if failed try: repo.git.checkout(repo.heads.master) return True - except: + except Exception: try: if remote_name is not None: repo.git.checkout('-b', 'master', f'{remote_name}/master') return True - except: + except Exception: try: repo.git.checkout(repo.heads.main) return True - except: + except Exception: try: if remote_name is not None: repo.git.checkout('-b', 'main', f'{remote_name}/main') return True - except: + except Exception: pass print("[ComfyUI Manager] Failed to switch to the default branch") @@ -447,7 +447,7 @@ def restore_pip_snapshot(pips, options): res = 1 try: res = subprocess.check_call([sys.executable, '-m', 'pip', 'install'] + non_url) - except: + except Exception: pass # fallback @@ -456,7 +456,7 @@ def restore_pip_snapshot(pips, options): res = 1 try: res = subprocess.check_call([sys.executable, '-m', 'pip', 'install', x]) - except: + except Exception: pass if res != 0: @@ -467,7 +467,7 @@ def restore_pip_snapshot(pips, options): res = 1 try: res = subprocess.check_call([sys.executable, '-m', 'pip', 'install', x]) - except: + except Exception: pass if res != 0: @@ -478,7 +478,7 @@ def restore_pip_snapshot(pips, options): res = 1 try: res = subprocess.check_call([sys.executable, '-m', 'pip', 'install', x]) - except: + except Exception: pass if res != 0: diff --git a/comfyui_manager/common/manager_util.py b/comfyui_manager/common/manager_util.py index 126723fd..6c0eb74a 100644 --- a/comfyui_manager/common/manager_util.py +++ b/comfyui_manager/common/manager_util.py @@ -54,7 +54,7 @@ def make_pip_cmd(cmd): # DON'T USE StrictVersion - cannot handle pre_release version # try: # from distutils.version import StrictVersion -# except: +# except Exception: # print(f"[ComfyUI-Manager] 'distutils' package not found. Activating fallback mode for compatibility.") class StrictVersion: def __init__(self, version_string): @@ -527,7 +527,7 @@ def robust_readlines(fullpath): try: with open(fullpath, "r") as f: return f.readlines() - except: + except Exception: encoding = None with open(fullpath, "rb") as f: raw_data = f.read() diff --git a/comfyui_manager/glob/manager_core.py b/comfyui_manager/glob/manager_core.py index fcc96106..e4d02e3e 100644 --- a/comfyui_manager/glob/manager_core.py +++ b/comfyui_manager/glob/manager_core.py @@ -63,7 +63,7 @@ def get_default_custom_nodes_path(): try: import folder_paths default_custom_nodes_path = folder_paths.get_folder_paths("custom_nodes")[0] - except: + except Exception: default_custom_nodes_path = os.path.abspath(os.path.join(manager_util.comfyui_manager_path, '..')) return default_custom_nodes_path @@ -73,7 +73,7 @@ def get_custom_nodes_paths(): try: import folder_paths return folder_paths.get_folder_paths("custom_nodes") - except: + except Exception: custom_nodes_path = os.path.abspath(os.path.join(manager_util.comfyui_manager_path, '..')) return [custom_nodes_path] @@ -110,11 +110,11 @@ def check_invalid_nodes(): try: import folder_paths - except: + except Exception: try: sys.path.append(context.comfy_path) import folder_paths - except: + except Exception: raise Exception(f"Invalid COMFYUI_FOLDERS_BASE_PATH: {context.comfy_path}") def check(root): @@ -778,7 +778,7 @@ class UnifiedManager: if 'id' in x: if x['id'] not in res: res[x['id']] = (x, True) - except: + except Exception: logging.error(f"[ComfyUI-Manager] broken item:{x}") return res @@ -831,7 +831,7 @@ class UnifiedManager: def safe_version(ver_str): try: return version.parse(ver_str) - except: + except Exception: return version.parse("0.0.0") def execute_install_script(self, url, repo_path, instant_execution=False, lazy_mode=False, no_deps=False): @@ -1499,7 +1499,7 @@ def identify_node_pack_from_path(fullpath): if github_id is None: try: github_id = os.path.basename(repo_url) - except: + except Exception: logging.warning(f"[ComfyUI-Manager] unexpected repo url: {repo_url}") github_id = module_name @@ -1724,27 +1724,27 @@ def switch_to_default_branch(repo): default_branch = repo.git.symbolic_ref(f'refs/remotes/{remote_name}/HEAD').replace(f'refs/remotes/{remote_name}/', '') repo.git.checkout(default_branch) return True - except: + except Exception: # try checkout master # try checkout main if failed try: repo.git.checkout(repo.heads.master) return True - except: + except Exception: try: if remote_name is not None: repo.git.checkout('-b', 'master', f'{remote_name}/master') return True - except: + except Exception: try: repo.git.checkout(repo.heads.main) return True - except: + except Exception: try: if remote_name is not None: repo.git.checkout('-b', 'main', f'{remote_name}/main') return True - except: + except Exception: pass print("[ComfyUI Manager] Failed to switch to the default branch") @@ -1795,7 +1795,7 @@ def try_install_script(url, repo_path, install_cmd, instant_execution=False): 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("[WARN] The extension installation feature may not work properly in the current installed ComfyUI version on Windows environment.") print("###################################################################\n\n") - except: + except Exception: pass if code != 0: @@ -2427,7 +2427,7 @@ def update_to_stable_comfyui(repo_path): repo = git.Repo(repo_path) try: repo.git.checkout(repo.heads.master) - except: + except Exception: logging.error(f"[ComfyUI-Manager] Failed to checkout 'master' branch.\nrepo_path={repo_path}\nAvailable branches:") for branch in repo.branches: logging.error('\t'+branch.name) @@ -2450,7 +2450,7 @@ def update_to_stable_comfyui(repo_path): logging.info(f"[ComfyUI-Manager] Updating ComfyUI: {current_tag} -> {latest_tag}") repo.git.checkout(latest_tag) return 'updated', latest_tag - except: + except Exception: traceback.print_exc() return "fail", None @@ -2648,7 +2648,7 @@ async def get_current_snapshot(custom_nodes_only = False): commit_hash = git_utils.get_commit_hash(fullpath) url = git_utils.git_url(fullpath) git_custom_nodes[url] = dict(hash=commit_hash, disabled=is_disabled) - except: + except Exception: print(f"Failed to extract snapshots for the custom node '{path}'.") elif path.endswith('.py'): @@ -2706,7 +2706,7 @@ async def extract_nodes_from_workflow(filepath, mode='local', channel_url='defau with open(filepath, "r", encoding="UTF-8", errors="ignore") as json_file: try: workflow = json.load(json_file) - except: + except Exception: print(f"Invalid workflow file: {filepath}") exit(-1) @@ -2719,7 +2719,7 @@ async def extract_nodes_from_workflow(filepath, mode='local', channel_url='defau else: try: workflow = json.loads(img.info['workflow']) - except: + except Exception: print(f"This is not a valid .png file containing a ComfyUI workflow: {filepath}") exit(-1) @@ -2990,7 +2990,7 @@ def populate_github_stats(node_packs, json_obj_github): v['stars'] = -1 v['last_update'] = -1 v['trust'] = False - except: + except Exception: logging.error(f"[ComfyUI-Manager] DB item is broken:\n{v}") @@ -3266,7 +3266,7 @@ def get_comfyui_versions(repo=None): try: remote = get_remote_name(repo) repo.remotes[remote].fetch() - except: + except Exception: logging.error("[ComfyUI-Manager] Failed to fetch ComfyUI") versions = [x.name for x in repo.tags if x.name.startswith('v')] @@ -3335,5 +3335,5 @@ def repo_switch_commit(repo_path, commit_hash): repo.git.checkout(commit_hash) return True - except: + except Exception: return None diff --git a/comfyui_manager/glob/manager_server.py b/comfyui_manager/glob/manager_server.py index efecbdb7..0bc73881 100644 --- a/comfyui_manager/glob/manager_server.py +++ b/comfyui_manager/glob/manager_server.py @@ -220,7 +220,7 @@ def print_comfyui_version(): try: if not os.environ.get('__COMFYUI_DESKTOP_VERSION__') and core.comfy_ui_commit_datetime.date() < core.comfy_ui_required_commit_datetime.date(): logging.warning(f"\n\n## [WARN] ComfyUI-Manager: Your ComfyUI version ({core.comfy_ui_revision})[{core.comfy_ui_commit_datetime.date()}] is too old. Please update to the latest version. ##\n\n") - except: + except Exception: pass # process on_revision_detected --> @@ -247,7 +247,7 @@ def print_comfyui_version(): logging.info(f"### ComfyUI Version: {comfyui_tag} on '{current_branch}' | Released on '{core.comfy_ui_commit_datetime.date()}'") else: logging.info(f"### ComfyUI Revision: {core.comfy_ui_revision} on '{current_branch}' [{comfy_ui_hash[:8]}] | Released on '{core.comfy_ui_commit_datetime.date()}'") - except: + except Exception: if is_detached: logging.info(f"### ComfyUI Revision: {core.comfy_ui_revision} [{comfy_ui_hash[:8]}] *DETACHED | Released on '{core.comfy_ui_commit_datetime.date()}'") else: @@ -899,7 +899,7 @@ async def fetch_updates(request): return web.Response(status=201) return web.Response(status=200) - except: + except Exception: traceback.print_exc() return web.Response(status=400) @@ -1163,7 +1163,7 @@ async def remove_snapshot(request): os.remove(path) return web.Response(status=200) - except: + except Exception: return web.Response(status=400) @@ -1189,7 +1189,7 @@ async def restore_snapshot(request): logging.error(f"Snapshot file not found: `{path}`") return web.Response(status=400) - except: + except Exception: return web.Response(status=400) @@ -1197,7 +1197,7 @@ async def restore_snapshot(request): async def get_current_snapshot_api(request): try: return web.json_response(await core.get_current_snapshot(), content_type='application/json') - except: + except Exception: return web.Response(status=400) @@ -1206,7 +1206,7 @@ async def save_snapshot(request): try: await core.save_snapshot_with_postfix('snapshot') return web.Response(status=200) - except: + except Exception: return web.Response(status=400) @@ -1754,7 +1754,7 @@ async def get_notice(request): markdown_content = '

Your ComfyUI isn\'t git repo.

' + markdown_content elif core.comfy_ui_required_commit_datetime.date() > core.comfy_ui_commit_datetime.date(): markdown_content = '

Your ComfyUI is too OUTDATED!!!

' + markdown_content - except: + except Exception: pass return web.Response(text=markdown_content, status=200) @@ -1833,7 +1833,7 @@ async def save_component(request): with open(filepath, 'w') as f: json.dump(components, f, indent=4, sort_keys=True) return web.Response(text=filepath, status=200) - except: + except Exception: return web.Response(status=400) diff --git a/comfyui_manager/glob/share_3rdparty.py b/comfyui_manager/glob/share_3rdparty.py index 64f68623..80ed1211 100644 --- a/comfyui_manager/glob/share_3rdparty.py +++ b/comfyui_manager/glob/share_3rdparty.py @@ -10,6 +10,7 @@ import hashlib import folder_paths from server import PromptServer +import logging def extract_model_file_names(json_data): @@ -73,7 +74,7 @@ def get_openart_auth(): with open(os.path.join(context.manager_files_path, ".openart_key"), "r") as f: openart_key = f.read().strip() return openart_key if openart_key else None - except: + except Exception: return None @@ -91,7 +92,7 @@ def get_matrix_auth(): "username": username, "password": password, } - except: + except Exception: return None @@ -104,7 +105,7 @@ def get_comfyworkflows_auth(): if not share_key.strip(): return None return share_key - except: + except Exception: return None @@ -115,7 +116,7 @@ def get_youml_settings(): with open(os.path.join(context.manager_files_path, ".youml"), "r") as f: youml_settings = f.read().strip() return youml_settings if youml_settings else None - except: + except Exception: return None @@ -235,7 +236,7 @@ async def share_art(request): try: output_to_share = potential_outputs[int(selected_output_index)] - except: + except Exception: # for now, pick the first output output_to_share = potential_outputs[0] @@ -352,7 +353,7 @@ async def share_art(request): token = client.login(username=matrix_auth['username'], password=matrix_auth['password']) if not token: return web.json_response({"error": "Invalid Matrix credentials."}, content_type='application/json', status=400) - except: + except Exception: return web.json_response({"error": "Invalid Matrix credentials."}, content_type='application/json', status=400) matrix = MatrixHttpApi(homeserver, token=token) @@ -371,9 +372,8 @@ async def share_art(request): 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() + except Exception: + logging.exception("An error occurred") return web.json_response({"error": "An error occurred when sharing your art to Matrix."}, content_type='application/json', status=500) return web.json_response({ diff --git a/comfyui_manager/legacy/manager_core.py b/comfyui_manager/legacy/manager_core.py index b763391e..77e07bb9 100644 --- a/comfyui_manager/legacy/manager_core.py +++ b/comfyui_manager/legacy/manager_core.py @@ -63,7 +63,7 @@ def get_default_custom_nodes_path(): try: import folder_paths default_custom_nodes_path = folder_paths.get_folder_paths("custom_nodes")[0] - except: + except Exception: default_custom_nodes_path = os.path.abspath(os.path.join(manager_util.comfyui_manager_path, '..')) return default_custom_nodes_path @@ -73,7 +73,7 @@ def get_custom_nodes_paths(): try: import folder_paths return folder_paths.get_folder_paths("custom_nodes") - except: + except Exception: custom_nodes_path = os.path.abspath(os.path.join(manager_util.comfyui_manager_path, '..')) return [custom_nodes_path] @@ -110,11 +110,11 @@ def check_invalid_nodes(): try: import folder_paths - except: + except Exception: try: sys.path.append(context.comfy_path) import folder_paths - except: + except Exception: raise Exception(f"Invalid COMFYUI_FOLDERS_BASE_PATH: {context.comfy_path}") def check(root): @@ -702,7 +702,7 @@ class UnifiedManager: if 'id' in x: if x['id'] not in res: res[x['id']] = (x, True) - except: + except Exception: logging.error(f"[ComfyUI-Manager] broken item:{x}") return res @@ -755,7 +755,7 @@ class UnifiedManager: def safe_version(ver_str): try: return version.parse(ver_str) - except: + except Exception: return version.parse("0.0.0") def execute_install_script(self, url, repo_path, instant_execution=False, lazy_mode=False, no_deps=False): @@ -1422,7 +1422,7 @@ def identify_node_pack_from_path(fullpath): if github_id is None: try: github_id = os.path.basename(repo_url) - except: + except Exception: logging.warning(f"[ComfyUI-Manager] unexpected repo url: {repo_url}") github_id = module_name @@ -1647,27 +1647,27 @@ def switch_to_default_branch(repo): default_branch = repo.git.symbolic_ref(f'refs/remotes/{remote_name}/HEAD').replace(f'refs/remotes/{remote_name}/', '') repo.git.checkout(default_branch) return True - except: + except Exception: # try checkout master # try checkout main if failed try: repo.git.checkout(repo.heads.master) return True - except: + except Exception: try: if remote_name is not None: repo.git.checkout('-b', 'master', f'{remote_name}/master') return True - except: + except Exception: try: repo.git.checkout(repo.heads.main) return True - except: + except Exception: try: if remote_name is not None: repo.git.checkout('-b', 'main', f'{remote_name}/main') return True - except: + except Exception: pass print("[ComfyUI Manager] Failed to switch to the default branch") @@ -1718,7 +1718,7 @@ def try_install_script(url, repo_path, install_cmd, instant_execution=False): 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("[WARN] The extension installation feature may not work properly in the current installed ComfyUI version on Windows environment.") print("###################################################################\n\n") - except: + except Exception: pass if code != 0: @@ -2336,7 +2336,7 @@ def update_to_stable_comfyui(repo_path): repo = git.Repo(repo_path) try: repo.git.checkout(repo.heads.master) - except: + except Exception: logging.error(f"[ComfyUI-Manager] Failed to checkout 'master' branch.\nrepo_path={repo_path}\nAvailable branches:") for branch in repo.branches: logging.error('\t'+branch.name) @@ -2359,7 +2359,7 @@ def update_to_stable_comfyui(repo_path): logging.info(f"[ComfyUI-Manager] Updating ComfyUI: {current_tag} -> {latest_tag}") repo.git.checkout(latest_tag) return 'updated', latest_tag - except: + except Exception: traceback.print_exc() return "fail", None @@ -2557,7 +2557,7 @@ async def get_current_snapshot(custom_nodes_only = False): commit_hash = git_utils.get_commit_hash(fullpath) url = git_utils.git_url(fullpath) git_custom_nodes[url] = dict(hash=commit_hash, disabled=is_disabled) - except: + except Exception: print(f"Failed to extract snapshots for the custom node '{path}'.") elif path.endswith('.py'): @@ -2615,7 +2615,7 @@ async def extract_nodes_from_workflow(filepath, mode='local', channel_url='defau with open(filepath, "r", encoding="UTF-8", errors="ignore") as json_file: try: workflow = json.load(json_file) - except: + except Exception: print(f"Invalid workflow file: {filepath}") exit(-1) @@ -2628,7 +2628,7 @@ async def extract_nodes_from_workflow(filepath, mode='local', channel_url='defau else: try: workflow = json.loads(img.info['workflow']) - except: + except Exception: print(f"This is not a valid .png file containing a ComfyUI workflow: {filepath}") exit(-1) @@ -2899,7 +2899,7 @@ def populate_github_stats(node_packs, json_obj_github): v['stars'] = -1 v['last_update'] = -1 v['trust'] = False - except: + except Exception: logging.error(f"[ComfyUI-Manager] DB item is broken:\n{v}") @@ -3175,7 +3175,7 @@ def get_comfyui_versions(repo=None): try: remote = get_remote_name(repo) repo.remotes[remote].fetch() - except: + except Exception: logging.error("[ComfyUI-Manager] Failed to fetch ComfyUI") versions = [x.name for x in repo.tags if x.name.startswith('v')] @@ -3244,5 +3244,5 @@ def repo_switch_commit(repo_path, commit_hash): repo.git.checkout(commit_hash) return True - except: + except Exception: return None diff --git a/comfyui_manager/legacy/manager_server.py b/comfyui_manager/legacy/manager_server.py index aa0c9ddf..6dcb9050 100644 --- a/comfyui_manager/legacy/manager_server.py +++ b/comfyui_manager/legacy/manager_server.py @@ -220,7 +220,7 @@ def print_comfyui_version(): try: if not os.environ.get('__COMFYUI_DESKTOP_VERSION__') and core.comfy_ui_commit_datetime.date() < core.comfy_ui_required_commit_datetime.date(): logging.warning(f"\n\n## [WARN] ComfyUI-Manager: Your ComfyUI version ({core.comfy_ui_revision})[{core.comfy_ui_commit_datetime.date()}] is too old. Please update to the latest version. ##\n\n") - except: + except Exception: pass # process on_revision_detected --> @@ -247,7 +247,7 @@ def print_comfyui_version(): logging.info(f"### ComfyUI Version: {comfyui_tag} on '{current_branch}' | Released on '{core.comfy_ui_commit_datetime.date()}'") else: logging.info(f"### ComfyUI Revision: {core.comfy_ui_revision} on '{current_branch}' [{comfy_ui_hash[:8]}] | Released on '{core.comfy_ui_commit_datetime.date()}'") - except: + except Exception: if is_detached: logging.info(f"### ComfyUI Revision: {core.comfy_ui_revision} [{comfy_ui_hash[:8]}] *DETACHED | Released on '{core.comfy_ui_commit_datetime.date()}'") else: @@ -896,7 +896,7 @@ async def fetch_updates(request): return web.Response(status=201) return web.Response(status=200) - except: + except Exception: traceback.print_exc() return web.Response(status=400) @@ -1162,7 +1162,7 @@ async def remove_snapshot(request): os.remove(path) return web.Response(status=200) - except: + except Exception: return web.Response(status=400) @@ -1188,7 +1188,7 @@ async def restore_snapshot(request): logging.error(f"Snapshot file not found: `{path}`") return web.Response(status=400) - except: + except Exception: return web.Response(status=400) @@ -1196,7 +1196,7 @@ async def restore_snapshot(request): async def get_current_snapshot_api(request): try: return web.json_response(await core.get_current_snapshot(), content_type='application/json') - except: + except Exception: return web.Response(status=400) @@ -1205,7 +1205,7 @@ async def save_snapshot(request): try: await core.save_snapshot_with_postfix('snapshot') return web.Response(status=200) - except: + except Exception: return web.Response(status=400) @@ -1753,7 +1753,7 @@ async def get_notice(request): markdown_content = '

Your ComfyUI isn\'t git repo.

' + markdown_content elif core.comfy_ui_required_commit_datetime.date() > core.comfy_ui_commit_datetime.date(): markdown_content = '

Your ComfyUI is too OUTDATED!!!

' + markdown_content - except: + except Exception: pass return web.Response(text=markdown_content, status=200) @@ -1832,7 +1832,7 @@ async def save_component(request): with open(filepath, 'w') as f: json.dump(components, f, indent=4, sort_keys=True) return web.Response(text=filepath, status=200) - except: + except Exception: return web.Response(status=400) diff --git a/comfyui_manager/legacy/share_3rdparty.py b/comfyui_manager/legacy/share_3rdparty.py index 64f68623..703cab08 100644 --- a/comfyui_manager/legacy/share_3rdparty.py +++ b/comfyui_manager/legacy/share_3rdparty.py @@ -73,7 +73,7 @@ def get_openart_auth(): with open(os.path.join(context.manager_files_path, ".openart_key"), "r") as f: openart_key = f.read().strip() return openart_key if openart_key else None - except: + except Exception: return None @@ -91,7 +91,7 @@ def get_matrix_auth(): "username": username, "password": password, } - except: + except Exception: return None @@ -104,7 +104,7 @@ def get_comfyworkflows_auth(): if not share_key.strip(): return None return share_key - except: + except Exception: return None @@ -115,7 +115,7 @@ def get_youml_settings(): with open(os.path.join(context.manager_files_path, ".youml"), "r") as f: youml_settings = f.read().strip() return youml_settings if youml_settings else None - except: + except Exception: return None @@ -235,7 +235,7 @@ async def share_art(request): try: output_to_share = potential_outputs[int(selected_output_index)] - except: + except Exception: # for now, pick the first output output_to_share = potential_outputs[0] @@ -352,7 +352,7 @@ async def share_art(request): token = client.login(username=matrix_auth['username'], password=matrix_auth['password']) if not token: return web.json_response({"error": "Invalid Matrix credentials."}, content_type='application/json', status=400) - except: + except Exception: return web.json_response({"error": "Invalid Matrix credentials."}, content_type='application/json', status=400) matrix = MatrixHttpApi(homeserver, token=token) @@ -371,7 +371,7 @@ async def share_art(request): 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: + except Exception: import traceback traceback.print_exc() return web.json_response({"error": "An error occurred when sharing your art to Matrix."}, content_type='application/json', status=500) diff --git a/comfyui_manager/prestartup_script.py b/comfyui_manager/prestartup_script.py index f0820f79..2ab0af2c 100644 --- a/comfyui_manager/prestartup_script.py +++ b/comfyui_manager/prestartup_script.py @@ -65,12 +65,8 @@ comfy_path = os.environ.get('COMFYUI_PATH') comfy_base_path = os.environ.get('COMFYUI_FOLDERS_BASE_PATH') if comfy_path is None: - try: - comfy_path = os.path.abspath(os.path.dirname(sys.modules['__main__'].__file__)) - os.environ['COMFYUI_PATH'] = comfy_path - except: - print("[ComfyUI-Manager] environment variable 'COMFYUI_PATH' is not specified.") - exit(-1) + comfy_path = os.path.abspath(os.path.dirname(sys.modules['__main__'].__file__)) + os.environ['COMFYUI_PATH'] = comfy_path if comfy_base_path is None: comfy_base_path = comfy_path @@ -438,35 +434,6 @@ except Exception as e: print(f"[ComfyUI-Manager] Logging failed: {e}") -def ensure_dependencies(): - try: - import git # noqa: F401 - import toml # noqa: F401 - import rich # noqa: F401 - import chardet # noqa: F401 - except ModuleNotFoundError: - my_path = os.path.dirname(__file__) - requirements_path = os.path.join(my_path, "requirements.txt") - - print("## ComfyUI-Manager: installing dependencies. (GitPython)") - try: - subprocess.check_output(manager_util.make_pip_cmd(['install', '-r', requirements_path])) - except subprocess.CalledProcessError: - print("## [ERROR] ComfyUI-Manager: Attempting to reinstall dependencies using an alternative method.") - try: - subprocess.check_output(manager_util.make_pip_cmd(['install', '--user', '-r', requirements_path])) - 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: - 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("## [ERROR] ComfyUI-Manager: GitPython package seems to be installed, but failed to load somehow. Make sure you have a working git client installed") - -ensure_dependencies() - - print("** ComfyUI startup time:", current_timestamp()) print("** Platform:", platform.system()) print("** Python version:", sys.version) @@ -490,7 +457,7 @@ def read_downgrade_blacklist(): items = [x.strip() for x in items if x != ''] cm_global.pip_downgrade_blacklist += items cm_global.pip_downgrade_blacklist = list(set(cm_global.pip_downgrade_blacklist)) - except: + except Exception: pass diff --git a/scanner.py b/scanner.py index bbd582d6..5ee1649c 100644 --- a/scanner.py +++ b/scanner.py @@ -94,7 +94,7 @@ def extract_nodes(code_text): return s else: return set() - except: + except Exception: return set() @@ -396,7 +396,7 @@ def update_custom_nodes(): try: download_url(url, temp_dir) - except: + except Exception: print(f"[ERROR] Cannot download '{url}'") with concurrent.futures.ThreadPoolExecutor(10) as executor: