修复编码错误以及时间格式问题
This commit is contained in:
+40
-7
@@ -55,13 +55,46 @@ def LogFileChecker(selfStamp):
|
||||
requareClear = CheckedLine == 0
|
||||
CheckedDateSec = fileDateSec
|
||||
resultText = ""
|
||||
with open(logFilePath, "r") as file:
|
||||
currentLine = 0
|
||||
for line in file:
|
||||
if currentLine > CheckedLine:
|
||||
CheckedLine = currentLine
|
||||
resultText += line + "\n"
|
||||
currentLine += 1
|
||||
try:
|
||||
# Try UTF-8 encoding first
|
||||
with open(logFilePath, "r", encoding="utf-8") as file:
|
||||
currentLine = 0
|
||||
for line in file:
|
||||
if currentLine > CheckedLine:
|
||||
CheckedLine = currentLine
|
||||
# 处理时间格式,移除毫秒部分
|
||||
if line.startswith("[20"):
|
||||
try:
|
||||
time_end = line.index("]")
|
||||
if time_end > 0:
|
||||
time_str = line[1:time_end]
|
||||
if "." in time_str:
|
||||
time_str = time_str.split(".")[0]
|
||||
line = "[" + time_str + "]" + line[time_end+1:]
|
||||
except:
|
||||
pass
|
||||
resultText += line + "\n"
|
||||
currentLine += 1
|
||||
except UnicodeDecodeError:
|
||||
# If UTF-8 fails, try with error handling
|
||||
with open(logFilePath, "r", encoding="utf-8", errors="replace") as file:
|
||||
currentLine = 0
|
||||
for line in file:
|
||||
if currentLine > CheckedLine:
|
||||
CheckedLine = currentLine
|
||||
# 处理时间格式,移除毫秒部分
|
||||
if line.startswith("[20"):
|
||||
try:
|
||||
time_end = line.index("]")
|
||||
if time_end > 0:
|
||||
time_str = line[1:time_end]
|
||||
if "." in time_str:
|
||||
time_str = time_str.split(".")[0]
|
||||
line = "[" + time_str + "]" + line[time_end+1:]
|
||||
except:
|
||||
pass
|
||||
resultText += line + "\n"
|
||||
currentLine += 1
|
||||
PromptServer.instance.send_sync(
|
||||
"/hotreload.terminal.log", {"text": resultText, "clear": requareClear}
|
||||
)
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "comfyui_lg_hotreload"
|
||||
description = "An extension for ComfyUI that allows hot reloading. Once installed, you can preview changes in real-time while developing custom nodes or installing plugins without restarting ComfyUI."
|
||||
version = "1.7.0"
|
||||
version = "1.7.1"
|
||||
dependencies = ["watchdog"]
|
||||
|
||||
[project.urls]
|
||||
|
||||
Reference in New Issue
Block a user