@weaxs/openclaw-stock-analysis 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/setup-python.mjs +10 -5
- package/scripts/sync-version.sh +3 -2
- package/scripts/venv-python.mjs +20 -0
- package/skills/bottom-volume/scripts/gather.py +7 -0
- package/skills/box-oscillation/scripts/gather.py +7 -0
- package/skills/bull-trend/scripts/gather.py +7 -0
- package/skills/chan-theory/scripts/gather.py +7 -0
- package/skills/dragon-head/scripts/gather.py +7 -0
- package/skills/emotion-cycle/scripts/gather.py +7 -0
- package/skills/event-driven/scripts/gather.py +7 -0
- package/skills/expectation-repricing/scripts/gather.py +7 -0
- package/skills/growth-quality/scripts/gather.py +7 -0
- package/skills/hot-theme/scripts/gather.py +7 -0
- package/skills/ma-crossover/scripts/gather.py +7 -0
- package/skills/market-review/scripts/gather.py +7 -0
- package/skills/one-yang-three-yin/scripts/gather.py +7 -0
- package/skills/shrink-pullback/scripts/gather.py +7 -0
- package/skills/stock-analysis/scripts/gather.py +7 -0
- package/skills/stock-screener/scripts/gather.py +7 -0
- package/skills/strategy-backtest/scripts/gather.py +7 -0
- package/skills/volume-breakout/scripts/gather.py +7 -0
- package/skills/wave-theory/scripts/gather.py +7 -0
- package/tools/alert_rules.py +6 -1
- package/tools/anomaly_detect.py +6 -1
- package/tools/backtest.py +6 -0
- package/tools/capabilities.py +5 -0
- package/tools/diagnostics.py +5 -0
- package/tools/gather.py +6 -1
- package/tools/import_parser.py +5 -0
- package/tools/market_regime.py +6 -1
- package/tools/market_review.py +6 -1
- package/tools/name_resolver.py +5 -0
- package/tools/pattern.py +6 -0
- package/tools/position_context.py +6 -1
- package/tools/report_renderer.py +5 -0
- package/tools/risk_screening.py +6 -1
- package/tools/screener.py +6 -0
- package/tools/search_intel.py +5 -0
- package/tools/stock_data.py +6 -0
- package/tools/technical.py +6 -0
- package/tools/trading_calendar.py +5 -0
- package/tools/volume_analysis.py +6 -0
- package/tools/watchlist.py +5 -0
- package/tools/watchlist_context.py +6 -1
package/package.json
CHANGED
package/scripts/setup-python.mjs
CHANGED
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
import { execSync } from "node:child_process";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { venvPythonPath } from "./venv-python.mjs";
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
// fileURLToPath (not URL.pathname) — the latter yields a bogus "/C:/..." path
|
|
9
|
+
// on Windows, which would put the venv in the wrong place or fail outright.
|
|
10
|
+
const pkgDir = fileURLToPath(new URL("..", import.meta.url));
|
|
8
11
|
const venvDir = join(pkgDir, ".venv");
|
|
9
|
-
|
|
12
|
+
// Drive pip through the venv's own python (`-m pip`) instead of a pip/pip.exe
|
|
13
|
+
// shim — resolves correctly on both POSIX (bin/python3) and Windows (Scripts/python.exe).
|
|
14
|
+
const venvPython = venvPythonPath(pkgDir);
|
|
10
15
|
const requirements = join(pkgDir, "tools", "requirements.txt");
|
|
11
16
|
|
|
12
17
|
function run(cmd) {
|
|
@@ -41,12 +46,12 @@ try {
|
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
if (existsSync(requirements)) {
|
|
44
|
-
run(`"${
|
|
49
|
+
run(`"${venvPython}" -m pip install -q -r "${requirements}"`);
|
|
45
50
|
}
|
|
46
51
|
} catch (err) {
|
|
47
52
|
console.warn(
|
|
48
53
|
`\n[pi-stock-analysis] Python setup failed: ${err.message}\n` +
|
|
49
|
-
"You can manually
|
|
54
|
+
"You can manually create the venv and install tools/requirements.txt with your platform's python.\n"
|
|
50
55
|
);
|
|
51
56
|
process.exit(0);
|
|
52
57
|
}
|
package/scripts/sync-version.sh
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
# - package.json (npm root package)
|
|
11
11
|
# - package-lock.json (kept in lockstep so `npm publish` doesn't warn)
|
|
12
12
|
# - openclaw/package.json (OpenClaw npm package version)
|
|
13
|
+
# - dsh/package.json (dsh npm package version)
|
|
13
14
|
#
|
|
14
15
|
# Idempotent: running twice with the same tag is a no-op.
|
|
15
16
|
set -euo pipefail
|
|
@@ -42,10 +43,10 @@ p.write_text(new)
|
|
|
42
43
|
print(f" pyproject.toml: {n} substitution(s)")
|
|
43
44
|
PY
|
|
44
45
|
|
|
45
|
-
# npm root and
|
|
46
|
+
# npm root and host sub-packages
|
|
46
47
|
# `npm version` refuses in a workspace unless we bypass with --no-git-tag-version
|
|
47
48
|
# --allow-same-version keeps it idempotent when the tag already matches.
|
|
48
|
-
for dir in "." "openclaw"; do
|
|
49
|
+
for dir in "." "openclaw" "dsh"; do
|
|
49
50
|
if [[ -f "$dir/package.json" ]]; then
|
|
50
51
|
(cd "$dir" && npm version "$VERSION" --no-git-tag-version --allow-same-version) >/dev/null
|
|
51
52
|
echo " $dir/package.json: bumped"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Canonical venv-python resolution, shared by the postinstall script and the
|
|
2
|
+
// e2e harnesses. Kept in one place so the Windows/POSIX shape can't drift
|
|
3
|
+
// (previously each site hardcoded its own Scripts/bin + python.exe/python3).
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
|
|
7
|
+
const isWin = process.platform === "win32";
|
|
8
|
+
|
|
9
|
+
// Windows venvs ship Scripts/python.exe (there is no python3); POSIX venvs ship bin/python3.
|
|
10
|
+
export function venvPythonPath(rootDir) {
|
|
11
|
+
return join(rootDir, ".venv", isWin ? "Scripts" : "bin", isWin ? "python.exe" : "python3");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Interpreter to actually invoke: the venv python when present, else the
|
|
15
|
+
// platform fallback — "python" on Windows, where a bare "python3" is usually
|
|
16
|
+
// the Microsoft Store stub.
|
|
17
|
+
export function resolvePython(rootDir) {
|
|
18
|
+
const venvPython = venvPythonPath(rootDir);
|
|
19
|
+
return existsSync(venvPython) ? venvPython : isWin ? "python" : "python3";
|
|
20
|
+
}
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "gather.py"), "technical", sys.argv[1], "--kline-count", "120"],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
)
|
|
14
21
|
sys.stdout.write(result.stdout)
|
|
15
22
|
sys.exit(result.returncode)
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "gather.py"), "technical", sys.argv[1], "--kline-count", "90"],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
)
|
|
14
21
|
sys.stdout.write(result.stdout)
|
|
15
22
|
sys.exit(result.returncode)
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "gather.py"), "technical", sys.argv[1], "--kline-count", "120"],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
)
|
|
14
21
|
sys.stdout.write(result.stdout)
|
|
15
22
|
sys.exit(result.returncode)
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "gather.py"), "technical", sys.argv[1], "--kline-count", "120"],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
)
|
|
14
21
|
sys.stdout.write(result.stdout)
|
|
15
22
|
sys.exit(result.returncode)
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "gather.py"), "technical", sys.argv[1], "--kline-count", "30", "--with-quote"],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
)
|
|
14
21
|
sys.stdout.write(result.stdout)
|
|
15
22
|
sys.exit(result.returncode)
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "gather.py"), "technical", sys.argv[1], "--kline-count", "60", "--with-quote"],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
)
|
|
14
21
|
sys.stdout.write(result.stdout)
|
|
15
22
|
sys.exit(result.returncode)
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "gather.py"), "fundamental", sys.argv[1]],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
)
|
|
14
21
|
sys.stdout.write(result.stdout)
|
|
15
22
|
sys.exit(result.returncode)
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "gather.py"), "fundamental", sys.argv[1]],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
)
|
|
14
21
|
sys.stdout.write(result.stdout)
|
|
15
22
|
sys.exit(result.returncode)
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "gather.py"), "fundamental", sys.argv[1]],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
)
|
|
14
21
|
sys.stdout.write(result.stdout)
|
|
15
22
|
sys.exit(result.returncode)
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "gather.py"), "fundamental", sys.argv[1]],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
)
|
|
14
21
|
sys.stdout.write(result.stdout)
|
|
15
22
|
sys.exit(result.returncode)
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "gather.py"), "technical", sys.argv[1], "--kline-count", "120"],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
)
|
|
14
21
|
sys.stdout.write(result.stdout)
|
|
15
22
|
sys.exit(result.returncode)
|
|
@@ -5,12 +5,19 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
market = sys.argv[1] if len(sys.argv) > 1 else "A"
|
|
9
15
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
10
16
|
result = subprocess.run(
|
|
11
17
|
[sys.executable, str(tools / "market_review.py"), "review", "--market", market],
|
|
12
18
|
capture_output=True,
|
|
13
19
|
text=True,
|
|
20
|
+
encoding="utf-8",
|
|
14
21
|
)
|
|
15
22
|
sys.stdout.write(result.stdout)
|
|
16
23
|
sys.exit(result.returncode)
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "gather.py"), "technical", sys.argv[1], "--kline-count", "30"],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
)
|
|
14
21
|
sys.stdout.write(result.stdout)
|
|
15
22
|
sys.exit(result.returncode)
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "gather.py"), "technical", sys.argv[1], "--kline-count", "60"],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
)
|
|
14
21
|
sys.stdout.write(result.stdout)
|
|
15
22
|
sys.exit(result.returncode)
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "gather.py"), "analysis", sys.argv[1]],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
)
|
|
14
21
|
sys.stdout.write(result.stdout)
|
|
15
22
|
sys.exit(result.returncode)
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "gather.py"), "screen"] + sys.argv[1:],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
)
|
|
14
21
|
sys.stdout.write(result.stdout)
|
|
15
22
|
sys.exit(result.returncode)
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "backtest.py"), "run"] + sys.argv[1:],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
timeout=120,
|
|
14
21
|
)
|
|
15
22
|
sys.stdout.write(result.stdout)
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "gather.py"), "technical", sys.argv[1], "--kline-count", "90"],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
)
|
|
14
21
|
sys.stdout.write(result.stdout)
|
|
15
22
|
sys.exit(result.returncode)
|
|
@@ -5,11 +5,18 @@ import subprocess
|
|
|
5
5
|
import sys
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
# Windows defaults stdio to a legacy code page (cp1252); force UTF-8 so the
|
|
9
|
+
# child's Chinese output both decodes and re-prints here without crashing.
|
|
10
|
+
for _s in (sys.stdout, sys.stderr):
|
|
11
|
+
if hasattr(_s, "reconfigure"):
|
|
12
|
+
_s.reconfigure(encoding="utf-8")
|
|
13
|
+
|
|
8
14
|
tools = Path(__file__).resolve().parents[2] / "tools"
|
|
9
15
|
result = subprocess.run(
|
|
10
16
|
[sys.executable, str(tools / "gather.py"), "technical", sys.argv[1], "--kline-count", "120"],
|
|
11
17
|
capture_output=True,
|
|
12
18
|
text=True,
|
|
19
|
+
encoding="utf-8",
|
|
13
20
|
)
|
|
14
21
|
sys.stdout.write(result.stdout)
|
|
15
22
|
sys.exit(result.returncode)
|
package/tools/alert_rules.py
CHANGED
|
@@ -25,7 +25,7 @@ def _find_python() -> str:
|
|
|
25
25
|
def _run_json(script: str, args: list[str], timeout: int = 30):
|
|
26
26
|
cmd = [_find_python(), str(TOOLS_DIR / script)] + args
|
|
27
27
|
try:
|
|
28
|
-
r = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
|
|
28
|
+
r = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8", timeout=timeout)
|
|
29
29
|
if r.returncode == 0 and r.stdout.strip():
|
|
30
30
|
return json.loads(r.stdout)
|
|
31
31
|
except Exception:
|
|
@@ -235,4 +235,9 @@ def main():
|
|
|
235
235
|
|
|
236
236
|
|
|
237
237
|
if __name__ == "__main__":
|
|
238
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
239
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
240
|
+
for _s in (sys.stdout, sys.stderr):
|
|
241
|
+
if hasattr(_s, "reconfigure"):
|
|
242
|
+
_s.reconfigure(encoding="utf-8")
|
|
238
243
|
main()
|
package/tools/anomaly_detect.py
CHANGED
|
@@ -22,7 +22,7 @@ TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
22
22
|
def _run_tool(script: str, args: str):
|
|
23
23
|
cmd = f"{sys.executable} {TOOLS_DIR}/{script} {args}"
|
|
24
24
|
try:
|
|
25
|
-
r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=30)
|
|
25
|
+
r = subprocess.run(cmd, shell=True, capture_output=True, text=True, encoding="utf-8", timeout=30)
|
|
26
26
|
if r.returncode == 0 and r.stdout.strip():
|
|
27
27
|
return json.loads(r.stdout)
|
|
28
28
|
except Exception:
|
|
@@ -567,4 +567,9 @@ def main():
|
|
|
567
567
|
|
|
568
568
|
|
|
569
569
|
if __name__ == "__main__":
|
|
570
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
571
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
572
|
+
for _s in (sys.stdout, sys.stderr):
|
|
573
|
+
if hasattr(_s, "reconfigure"):
|
|
574
|
+
_s.reconfigure(encoding="utf-8")
|
|
570
575
|
main()
|
package/tools/backtest.py
CHANGED
|
@@ -68,6 +68,7 @@ def fetch_kline(symbol: str, start: str | None, end: str | None) -> pd.DataFrame
|
|
|
68
68
|
[sys.executable, script, "kline", symbol, "--period", "daily", "--count", str(count)],
|
|
69
69
|
capture_output=True,
|
|
70
70
|
text=True,
|
|
71
|
+
encoding="utf-8",
|
|
71
72
|
)
|
|
72
73
|
data = json.loads(r.stdout)
|
|
73
74
|
if isinstance(data, dict) and "error" in data:
|
|
@@ -755,4 +756,9 @@ def main():
|
|
|
755
756
|
|
|
756
757
|
|
|
757
758
|
if __name__ == "__main__":
|
|
759
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
760
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
761
|
+
for _s in (sys.stdout, sys.stderr):
|
|
762
|
+
if hasattr(_s, "reconfigure"):
|
|
763
|
+
_s.reconfigure(encoding="utf-8")
|
|
758
764
|
main()
|
package/tools/capabilities.py
CHANGED
|
@@ -100,4 +100,9 @@ def main():
|
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
if __name__ == "__main__":
|
|
103
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
104
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
105
|
+
for _s in (sys.stdout, sys.stderr):
|
|
106
|
+
if hasattr(_s, "reconfigure"):
|
|
107
|
+
_s.reconfigure(encoding="utf-8")
|
|
103
108
|
main()
|
package/tools/diagnostics.py
CHANGED
|
@@ -138,4 +138,9 @@ def main():
|
|
|
138
138
|
|
|
139
139
|
|
|
140
140
|
if __name__ == "__main__":
|
|
141
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
142
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
143
|
+
for _s in (sys.stdout, sys.stderr):
|
|
144
|
+
if hasattr(_s, "reconfigure"):
|
|
145
|
+
_s.reconfigure(encoding="utf-8")
|
|
141
146
|
main()
|
package/tools/gather.py
CHANGED
|
@@ -22,7 +22,7 @@ def _run(script: str, args: list[str], timeout: int = 60) -> str | None:
|
|
|
22
22
|
python = _find_python()
|
|
23
23
|
cmd = [python, str(TOOLS_DIR / script)] + args
|
|
24
24
|
try:
|
|
25
|
-
r = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
|
|
25
|
+
r = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8", timeout=timeout)
|
|
26
26
|
if r.returncode == 0 and r.stdout.strip():
|
|
27
27
|
return r.stdout.strip()
|
|
28
28
|
except subprocess.TimeoutExpired:
|
|
@@ -149,4 +149,9 @@ def main():
|
|
|
149
149
|
|
|
150
150
|
|
|
151
151
|
if __name__ == "__main__":
|
|
152
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
153
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
154
|
+
for _s in (sys.stdout, sys.stderr):
|
|
155
|
+
if hasattr(_s, "reconfigure"):
|
|
156
|
+
_s.reconfigure(encoding="utf-8")
|
|
152
157
|
main()
|
package/tools/import_parser.py
CHANGED
|
@@ -271,4 +271,9 @@ def main():
|
|
|
271
271
|
|
|
272
272
|
|
|
273
273
|
if __name__ == "__main__":
|
|
274
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
275
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
276
|
+
for _s in (sys.stdout, sys.stderr):
|
|
277
|
+
if hasattr(_s, "reconfigure"):
|
|
278
|
+
_s.reconfigure(encoding="utf-8")
|
|
274
279
|
main()
|
package/tools/market_regime.py
CHANGED
|
@@ -13,7 +13,7 @@ TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
13
13
|
def _run_tool(script: str, args: str) -> dict | list:
|
|
14
14
|
cmd = f"python3 {TOOLS_DIR}/{script} {args}"
|
|
15
15
|
try:
|
|
16
|
-
r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=30)
|
|
16
|
+
r = subprocess.run(cmd, shell=True, capture_output=True, text=True, encoding="utf-8", timeout=30)
|
|
17
17
|
if r.returncode == 0 and r.stdout.strip():
|
|
18
18
|
return json.loads(r.stdout)
|
|
19
19
|
except Exception:
|
|
@@ -244,4 +244,9 @@ def main():
|
|
|
244
244
|
|
|
245
245
|
|
|
246
246
|
if __name__ == "__main__":
|
|
247
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
248
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
249
|
+
for _s in (sys.stdout, sys.stderr):
|
|
250
|
+
if hasattr(_s, "reconfigure"):
|
|
251
|
+
_s.reconfigure(encoding="utf-8")
|
|
247
252
|
main()
|
package/tools/market_review.py
CHANGED
|
@@ -14,7 +14,7 @@ TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
14
14
|
def _run_tool(script: str, args: str, timeout: int = 30):
|
|
15
15
|
cmd = [sys.executable, os.path.join(TOOLS_DIR, script)] + args.split()
|
|
16
16
|
try:
|
|
17
|
-
r = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
|
|
17
|
+
r = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8", timeout=timeout)
|
|
18
18
|
if r.returncode == 0 and r.stdout.strip():
|
|
19
19
|
return json.loads(r.stdout)
|
|
20
20
|
except Exception:
|
|
@@ -147,4 +147,9 @@ def main():
|
|
|
147
147
|
|
|
148
148
|
|
|
149
149
|
if __name__ == "__main__":
|
|
150
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
151
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
152
|
+
for _s in (sys.stdout, sys.stderr):
|
|
153
|
+
if hasattr(_s, "reconfigure"):
|
|
154
|
+
_s.reconfigure(encoding="utf-8")
|
|
150
155
|
main()
|
package/tools/name_resolver.py
CHANGED
|
@@ -128,4 +128,9 @@ def main():
|
|
|
128
128
|
|
|
129
129
|
|
|
130
130
|
if __name__ == "__main__":
|
|
131
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
132
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
133
|
+
for _s in (sys.stdout, sys.stderr):
|
|
134
|
+
if hasattr(_s, "reconfigure"):
|
|
135
|
+
_s.reconfigure(encoding="utf-8")
|
|
131
136
|
main()
|
package/tools/pattern.py
CHANGED
|
@@ -17,6 +17,7 @@ def fetch_kline(symbol: str, period: str = "daily", count: int = 60) -> list:
|
|
|
17
17
|
[sys.executable, script, "kline", symbol, "--period", period, "--count", str(count)],
|
|
18
18
|
capture_output=True,
|
|
19
19
|
text=True,
|
|
20
|
+
encoding="utf-8",
|
|
20
21
|
)
|
|
21
22
|
return json.loads(r.stdout)
|
|
22
23
|
|
|
@@ -506,4 +507,9 @@ def main():
|
|
|
506
507
|
|
|
507
508
|
|
|
508
509
|
if __name__ == "__main__":
|
|
510
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
511
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
512
|
+
for _s in (sys.stdout, sys.stderr):
|
|
513
|
+
if hasattr(_s, "reconfigure"):
|
|
514
|
+
_s.reconfigure(encoding="utf-8")
|
|
509
515
|
main()
|
|
@@ -25,7 +25,7 @@ def _find_python() -> str:
|
|
|
25
25
|
def _run_json(script: str, args: list[str], timeout: int = 30):
|
|
26
26
|
cmd = [_find_python(), str(TOOLS_DIR / script)] + args
|
|
27
27
|
try:
|
|
28
|
-
r = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
|
|
28
|
+
r = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8", timeout=timeout)
|
|
29
29
|
if r.returncode == 0 and r.stdout.strip():
|
|
30
30
|
return json.loads(r.stdout)
|
|
31
31
|
except Exception:
|
|
@@ -153,4 +153,9 @@ def main():
|
|
|
153
153
|
|
|
154
154
|
|
|
155
155
|
if __name__ == "__main__":
|
|
156
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
157
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
158
|
+
for _s in (sys.stdout, sys.stderr):
|
|
159
|
+
if hasattr(_s, "reconfigure"):
|
|
160
|
+
_s.reconfigure(encoding="utf-8")
|
|
156
161
|
main()
|
package/tools/report_renderer.py
CHANGED
|
@@ -108,4 +108,9 @@ def main():
|
|
|
108
108
|
|
|
109
109
|
|
|
110
110
|
if __name__ == "__main__":
|
|
111
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
112
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
113
|
+
for _s in (sys.stdout, sys.stderr):
|
|
114
|
+
if hasattr(_s, "reconfigure"):
|
|
115
|
+
_s.reconfigure(encoding="utf-8")
|
|
111
116
|
main()
|
package/tools/risk_screening.py
CHANGED
|
@@ -14,7 +14,7 @@ TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
14
14
|
def _run_tool(script: str, args: str) -> dict:
|
|
15
15
|
cmd = f"python3 {TOOLS_DIR}/{script} {args}"
|
|
16
16
|
try:
|
|
17
|
-
r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=30)
|
|
17
|
+
r = subprocess.run(cmd, shell=True, capture_output=True, text=True, encoding="utf-8", timeout=30)
|
|
18
18
|
if r.returncode == 0 and r.stdout.strip():
|
|
19
19
|
return json.loads(r.stdout)
|
|
20
20
|
except Exception:
|
|
@@ -315,4 +315,9 @@ def main():
|
|
|
315
315
|
|
|
316
316
|
|
|
317
317
|
if __name__ == "__main__":
|
|
318
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
319
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
320
|
+
for _s in (sys.stdout, sys.stderr):
|
|
321
|
+
if hasattr(_s, "reconfigure"):
|
|
322
|
+
_s.reconfigure(encoding="utf-8")
|
|
318
323
|
main()
|
package/tools/screener.py
CHANGED
|
@@ -31,6 +31,7 @@ def fetch_snapshot(market: str) -> list:
|
|
|
31
31
|
[sys.executable, script, "market_snapshot", "--market", market],
|
|
32
32
|
capture_output=True,
|
|
33
33
|
text=True,
|
|
34
|
+
encoding="utf-8",
|
|
34
35
|
)
|
|
35
36
|
return json.loads(r.stdout)
|
|
36
37
|
|
|
@@ -210,4 +211,9 @@ def main():
|
|
|
210
211
|
|
|
211
212
|
|
|
212
213
|
if __name__ == "__main__":
|
|
214
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
215
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
216
|
+
for _s in (sys.stdout, sys.stderr):
|
|
217
|
+
if hasattr(_s, "reconfigure"):
|
|
218
|
+
_s.reconfigure(encoding="utf-8")
|
|
213
219
|
main()
|
package/tools/search_intel.py
CHANGED
|
@@ -496,4 +496,9 @@ def main():
|
|
|
496
496
|
|
|
497
497
|
|
|
498
498
|
if __name__ == "__main__":
|
|
499
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
500
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
501
|
+
for _s in (sys.stdout, sys.stderr):
|
|
502
|
+
if hasattr(_s, "reconfigure"):
|
|
503
|
+
_s.reconfigure(encoding="utf-8")
|
|
499
504
|
main()
|
package/tools/stock_data.py
CHANGED
|
@@ -973,6 +973,7 @@ def _news_search_intel_fallback(symbol: str) -> list:
|
|
|
973
973
|
[sys.executable, str(tools_dir / "search_intel.py"), "search", f"{symbol} 最新消息"],
|
|
974
974
|
capture_output=True,
|
|
975
975
|
text=True,
|
|
976
|
+
encoding="utf-8",
|
|
976
977
|
timeout=30,
|
|
977
978
|
)
|
|
978
979
|
except (subprocess.TimeoutExpired, OSError):
|
|
@@ -1712,4 +1713,9 @@ def main():
|
|
|
1712
1713
|
|
|
1713
1714
|
|
|
1714
1715
|
if __name__ == "__main__":
|
|
1716
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
1717
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
1718
|
+
for _s in (sys.stdout, sys.stderr):
|
|
1719
|
+
if hasattr(_s, "reconfigure"):
|
|
1720
|
+
_s.reconfigure(encoding="utf-8")
|
|
1715
1721
|
main()
|
package/tools/technical.py
CHANGED
|
@@ -17,6 +17,7 @@ def fetch_kline(symbol: str, period: str = "daily", count: int = 120) -> list:
|
|
|
17
17
|
[sys.executable, script, "kline", symbol, "--period", period, "--count", str(count)],
|
|
18
18
|
capture_output=True,
|
|
19
19
|
text=True,
|
|
20
|
+
encoding="utf-8",
|
|
20
21
|
)
|
|
21
22
|
return json.loads(r.stdout)
|
|
22
23
|
|
|
@@ -633,4 +634,9 @@ def main():
|
|
|
633
634
|
|
|
634
635
|
|
|
635
636
|
if __name__ == "__main__":
|
|
637
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
638
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
639
|
+
for _s in (sys.stdout, sys.stderr):
|
|
640
|
+
if hasattr(_s, "reconfigure"):
|
|
641
|
+
_s.reconfigure(encoding="utf-8")
|
|
636
642
|
main()
|
|
@@ -218,4 +218,9 @@ def main():
|
|
|
218
218
|
|
|
219
219
|
|
|
220
220
|
if __name__ == "__main__":
|
|
221
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
222
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
223
|
+
for _s in (sys.stdout, sys.stderr):
|
|
224
|
+
if hasattr(_s, "reconfigure"):
|
|
225
|
+
_s.reconfigure(encoding="utf-8")
|
|
221
226
|
main()
|
package/tools/volume_analysis.py
CHANGED
|
@@ -17,6 +17,7 @@ def fetch_kline(symbol: str, period: str = "daily", count: int = 60) -> list:
|
|
|
17
17
|
[sys.executable, script, "kline", symbol, "--period", period, "--count", str(count)],
|
|
18
18
|
capture_output=True,
|
|
19
19
|
text=True,
|
|
20
|
+
encoding="utf-8",
|
|
20
21
|
)
|
|
21
22
|
return json.loads(r.stdout)
|
|
22
23
|
|
|
@@ -169,4 +170,9 @@ def main():
|
|
|
169
170
|
|
|
170
171
|
|
|
171
172
|
if __name__ == "__main__":
|
|
173
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
174
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
175
|
+
for _s in (sys.stdout, sys.stderr):
|
|
176
|
+
if hasattr(_s, "reconfigure"):
|
|
177
|
+
_s.reconfigure(encoding="utf-8")
|
|
172
178
|
main()
|
package/tools/watchlist.py
CHANGED
|
@@ -58,4 +58,9 @@ def main():
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
if __name__ == "__main__":
|
|
61
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
62
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
63
|
+
for _s in (sys.stdout, sys.stderr):
|
|
64
|
+
if hasattr(_s, "reconfigure"):
|
|
65
|
+
_s.reconfigure(encoding="utf-8")
|
|
61
66
|
main()
|
|
@@ -28,7 +28,7 @@ def _find_python() -> str:
|
|
|
28
28
|
def _run_json(script: str, args: list[str], timeout: int = 30):
|
|
29
29
|
cmd = [_find_python(), str(TOOLS_DIR / script)] + args
|
|
30
30
|
try:
|
|
31
|
-
r = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
|
|
31
|
+
r = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8", timeout=timeout)
|
|
32
32
|
if r.returncode == 0 and r.stdout.strip():
|
|
33
33
|
return json.loads(r.stdout)
|
|
34
34
|
except Exception:
|
|
@@ -177,4 +177,9 @@ def main():
|
|
|
177
177
|
|
|
178
178
|
|
|
179
179
|
if __name__ == "__main__":
|
|
180
|
+
# Windows defaults stdio to a legacy code page (cp1252) that cannot encode the
|
|
181
|
+
# Chinese text these tools emit — force UTF-8 so stdout never crashes there.
|
|
182
|
+
for _s in (sys.stdout, sys.stderr):
|
|
183
|
+
if hasattr(_s, "reconfigure"):
|
|
184
|
+
_s.reconfigure(encoding="utf-8")
|
|
180
185
|
main()
|