mirror of
https://git.datalinker.icu/ltdrdata/ComfyUI-Manager
synced 2025-12-09 14:14:54 +08:00
improve: better log
This commit is contained in:
parent
b93e541478
commit
496ebf60c3
@ -33,7 +33,7 @@ sys.path.append('../..')
|
||||
from torchvision.datasets.utils import download_url
|
||||
|
||||
# ensure .js
|
||||
print("### Loading: ComfyUI-Manager (V0.21.2)")
|
||||
print("### Loading: ComfyUI-Manager (V0.21.3)")
|
||||
|
||||
comfy_ui_required_revision = 1240
|
||||
comfy_ui_revision = "Unknown"
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
import datetime
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import sys
|
||||
import os
|
||||
import atexit
|
||||
import threading
|
||||
|
||||
# Logger setup
|
||||
if os.path.exists("comfyui.log"):
|
||||
@ -15,7 +14,6 @@ if os.path.exists("comfyui.log"):
|
||||
original_stdout = sys.stdout
|
||||
original_stderr = sys.stderr
|
||||
|
||||
|
||||
class Logger:
|
||||
def __init__(self, filename):
|
||||
self.file = open(filename, "a")
|
||||
@ -34,6 +32,11 @@ class Logger:
|
||||
self.file.close()
|
||||
|
||||
|
||||
def handle_stream(stream, prefix):
|
||||
for line in stream:
|
||||
print(prefix, line, end="")
|
||||
|
||||
|
||||
sys.stdout = Logger("comfyui.log")
|
||||
sys.stderr = sys.stdout
|
||||
|
||||
@ -61,12 +64,23 @@ if os.path.exists(script_list_path):
|
||||
|
||||
try:
|
||||
script = eval(line)
|
||||
print(f"\n## ComfyUI-Manager: EXECUTE => {script}")
|
||||
print(f"\n## ComfyUI-Manager: EXECUTE => {script[1:]}")
|
||||
|
||||
print(f"\n## Execute install/(de)activation script for '{script[0]}'")
|
||||
code = subprocess.run(script[1:], cwd=script[0])
|
||||
process = subprocess.Popen(script[1:], cwd=script[0], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, bufsize=1)
|
||||
|
||||
if code.returncode != 0:
|
||||
stdout_thread = threading.Thread(target=handle_stream, args=(process.stdout, ""))
|
||||
stderr_thread = threading.Thread(target=handle_stream, args=(process.stderr, "[!]"))
|
||||
|
||||
stdout_thread.start()
|
||||
stderr_thread.start()
|
||||
|
||||
stdout_thread.join()
|
||||
stderr_thread.join()
|
||||
|
||||
exit_code = process.wait()
|
||||
|
||||
if exit_code != 0:
|
||||
print(f"install/(de)activation script failed: {script[0]}")
|
||||
except Exception as e:
|
||||
print(f"[ERROR] Failed to execute install/(de)activation script: {line} / {e}")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user