48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Peek at QMT client logs (GBK-encoded) around the restart window.
|
|
Prints ASCII-escaped so nothing dies on the GBK console."""
|
|
import datetime
|
|
import io
|
|
import os
|
|
|
|
|
|
def esc(s):
|
|
return str(s).encode("unicode_escape").decode("ascii")[:200]
|
|
|
|
|
|
d = open(r"C:\sanguo_bigqmt\qmt_install_dir.txt", encoding="utf-8").read().strip()
|
|
root = os.path.dirname(d)
|
|
logdir = os.path.join(root, "userdata", "log")
|
|
|
|
|
|
def tail(path, n=40):
|
|
try:
|
|
with io.open(path, "r", encoding="gbk", errors="replace") as f:
|
|
lines = f.readlines()
|
|
return lines[-n:]
|
|
except OSError as e:
|
|
return ["<%s>" % e]
|
|
|
|
|
|
f1 = os.path.join(logdir, "XtClient_Formula_20260909.log")
|
|
print("=== tail XtClient_Formula (%s) ===" % esc(f1))
|
|
for ln in tail(f1, 35):
|
|
print(" ", esc(ln.rstrip()))
|
|
|
|
f2 = os.path.join(logdir, "XtClient_20260909.log")
|
|
print("=== grep XtClient (model/strategy/auto/formula/python, after 19:2x) ===")
|
|
kws = ("模型", "策略", "自动", "formula", "Formula", "Model", "python", "Python",
|
|
"auto", "Auto", "恢复", "异常")
|
|
try:
|
|
with io.open(f2, "r", encoding="gbk", errors="replace") as f:
|
|
for ln in f:
|
|
if any(k in ln for k in kws) and ("19:2" in ln or "19:3" in ln):
|
|
print(" ", esc(ln.rstrip()))
|
|
except OSError as e:
|
|
print(" ", e)
|
|
|
|
f3 = os.path.join(logdir, "XtClient_FormulaOutput_20260909.log")
|
|
print("=== tail FormulaOutput ===")
|
|
for ln in tail(f3, 15):
|
|
print(" ", esc(ln.rstrip()))
|