24 라인
1.3 KiB
Python
"""Developer: launch the testing terminal with TF_ProbeHost on GOLD.pro M1, print PROBE journal lines, then close it (path-scoped kill)."""
| |||
import os, subprocess, time
| |||
from pathlib import Path
| |||
D = Path(os.environ.get("TF_DATA", r"C:\Users\gebruiker\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075"))
| |||
EXE = os.environ.get("TF_EXE", r"C:\Program Files\MetaTrader 5\terminal64.exe")
| |||
def kill():
| |||
subprocess.run(["powershell", "-NoProfile", "-Command", "Get-Process terminal64 -EA SilentlyContinue | Where-Object {$_.Path -eq '%s'} | Stop-Process -Force" % EXE])
| |||
ini = Path(os.environ["TEMP"]) / "tf_probe.ini"
| |||
ini.write_bytes(b"\xff\xfe" + "[StartUp]\nExpert=Tick_Forge\TF_ProbeHost\nSymbol=GOLD.pro\nPeriod=M1\n".replace("\n", "\r\n").encode("utf-16-le"))
| |||
kill(); time.sleep(2)
| |||
for l in (D / "MQL5/Logs").glob("*.log"):
| |||
try: l.rename(l.with_suffix(".bak%d" % int(time.time())))
| |||
except OSError: pass
| |||
subprocess.Popen([EXE, "/config:%s" % ini])
| |||
t0 = time.time(); lines = []
| |||
while time.time() - t0 < 120:
| |||
time.sleep(4)
| |||
logs = sorted((D / "MQL5/Logs").glob("*.log"))
| |||
if logs:
| |||
lines = logs[-1].read_bytes().decode("utf-16-le", "ignore").splitlines()
| |||
if any("after sleep" in x for x in lines): break
| |||
for x in lines:
| |||
if "PROBE" in x: print(x.encode("ascii", "ignore").decode()[:200])
| |||
kill()
|