From a11fbd190a818ac1c45f19489e8a481a02f3ced6 Mon Sep 17 00:00:00 2001 From: WAS Date: Sun, 8 Oct 2023 07:52:25 -0700 Subject: [PATCH] Update __init__.py --- __init__.py | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/__init__.py b/__init__.py index 36f73a7..446b334 100644 --- a/__init__.py +++ b/__init__.py @@ -1,39 +1,55 @@ import importlib +import traceback import time +from cstr import cstr + +#! MESSAGE TEMPLATES +cstr.color.add_code("msg", f"{cstr.color.LIGHTBLUE}WAS Extras: {cstr.color.END}") +cstr.color.add_code("warning", f"{cstr.color.LIGHTBLUE}WAS Extras {cstr.color.LIGHTYELLOW}Warning: {cstr.color.END}") +cstr.color.add_code("error", f"{cstr.color.LIGHTRED}WAS Extras {cstr.color.END}Error: {cstr.color.END}") + extras = [ ".ConditioningBlend", ".DebugThis", ".VAEEncodeForInpaint", ".VividSharpen", + ".ksampler_sequence" ] NODE_CLASS_MAPPINGS = {} NODE_DISPLAY_NAME_MAPPINGS = {} module_timings = {} -print("[\033[94m\033[1mWAS Extras\033[0m] Loading extra custom nodes...") +cstr("Loading extra custom nodes...").msg.print() + for module_name in extras: start_time = time.time() - + success = True + error = None try: module = importlib.import_module(module_name, package=__name__) - except Exception: + except Exception as e: + error = e success = False - pass - + traceback.print_exc() + end_time = time.time() timing = end_time - start_time - - module_timings[module.__file__] = (timing, success) + + if success: + module_timings[module.__file__] = (timing, success, error) NODE_CLASS_MAPPINGS.update(getattr(module, 'NODE_CLASS_MAPPINGS', {})) NODE_DISPLAY_NAME_MAPPINGS.update(getattr(module, 'NODE_DISPLAY_NAME_MAPPINGS', {})) + __all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] -print("[\033[94m\033[1mWAS Extras\033[0m] Import times for extras:") -for module, (timing, success) in module_timings.items(): +cstr("Import times for extras:").msg.print() +for module, (timing, success, error) in module_timings.items(): print(f" {timing:.1f} seconds{('' if success else ' (IMPORT FAILED)')}: {module}") + if error: + print("Error:", error)