forked from MrForExample/ComfyUI-3D-Pack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
76 lines (56 loc) · 2.13 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import os
import sys
import logging
import folder_paths as comfy_paths
from pyhocon import ConfigFactory
ROOT_PATH = os.path.join(comfy_paths.get_folder_paths("custom_nodes")[0], "ComfyUI-3D-Pack")
sys.path.append(ROOT_PATH)
import shutil
import __main__
import importlib
import inspect
from .webserver.server import server, set_web_conf
# Set logging
logger = logging.getLogger('transformers')
for handler in logger.handlers:
logger.removeHandler(handler)
logging_level = logging.WARNING # This is the default for transformers
logger.setLevel(logging_level)
stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.setLevel(logging.WARNING)
stdout_handler.addFilter(lambda record: record.levelno <= logging.WARNING)
stderr_handler = logging.StreamHandler(sys.stderr)
stderr_handler.setLevel(logging.ERROR)
formatter = logging.Formatter('%(message)s')
stdout_handler.setFormatter(formatter)
stderr_handler.setFormatter(formatter)
logger.addHandler(stdout_handler)
logger.addHandler(stderr_handler)
conf_path = os.path.join(ROOT_PATH, "configs/system.conf")
# Configuration
f = open(conf_path)
conf_text = f.read()
f.close()
sys_conf = ConfigFactory.parse_string(conf_text)
set_web_conf(sys_conf['web'])
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
nodes_filename = "nodes"
module = importlib.import_module(f".{nodes_filename}", package=__name__)
for name, cls in inspect.getmembers(module, inspect.isclass):
if cls.__module__ == module.__name__:
name = name.replace("_", " ")
node = f"[Comfy3D] {name}"
disp = f"{name}"
NODE_CLASS_MAPPINGS[node] = cls
NODE_DISPLAY_NAME_MAPPINGS[node] = disp
WEB_DIRECTORY = "./web"
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS', 'WEB_DIRECTORY']
# # Cleanup old extension folder
folder_web = os.path.join(os.path.dirname(os.path.realpath(__main__.__file__)), "web")
extensions_folder = os.path.join(folder_web, 'extensions', 'ComfyUI-3D-Pack')
def cleanup():
if os.path.exists(extensions_folder):
shutil.rmtree(extensions_folder)
print('\033[34mComfy3D: \033[92mRemoved old extension folder\033[0m')
cleanup()