Files
sanguo_vnpy_v2/scripts/qmt_relogin/qmt_pypeek.py
T

42 lines
1.6 KiB
Python

# -*- coding: utf-8 -*-
"""Inspect <install>/python (strategy scripts) + hunt strategy registry files."""
import os
import time
d = open(r"C:\sanguo_bigqmt\qmt_install_dir.txt", encoding="utf-8").read().strip()
root = os.path.dirname(d)
pydir = os.path.join(root, "python")
print("=== %s ===" % pydir.encode("unicode_escape").decode("ascii"))
if os.path.isdir(pydir):
for f in sorted(os.listdir(pydir)):
p = os.path.join(pydir, f)
st = os.stat(p)
print(" %-50s %9d %s" % (
f.encode("unicode_escape").decode("ascii")[:50], st.st_size,
time.strftime("%m-%d %H:%M", time.localtime(st.st_mtime))))
else:
print(" MISSING")
# strategy registry candidates anywhere under install root (small config-ish files
# mentioning formula), excluding logs/data dirs we already know
print("=== hunting registry candidates ===")
skip = {"log", "dumps"}
for dirpath, dirnames, files in os.walk(root):
dirnames[:] = [x for x in dirnames if x not in skip and not x.startswith("bin")]
rel = os.path.relpath(dirpath, root)
depth = rel.count(os.sep)
if depth > 3:
dirnames[:] = []
continue
for f in files:
low = f.lower()
if any(k in low for k in ("formula", "strategy", "model")) and \
low.endswith((".xml", ".json", ".ini", ".dat", ".cfg", ".db")):
p = os.path.join(dirpath, f)
st = os.stat(p)
print(" %-70s %8d %s" % (
os.path.join(rel, f).encode("unicode_escape").decode("ascii")[:70],
st.st_size,
time.strftime("%m-%d %H:%M", time.localtime(st.st_mtime))))