@danhachuel/thunderbolt 0.4.82 → 0.4.84
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/app/main.py +9 -2
- package/hermes_ui/automation_worker.py +9 -2
- package/hermes_ui/pipeline_worker.py +9 -2
- package/package.json +2 -1
- package/scripts/cli.mjs +7 -4
- package/scripts/install.mjs +3 -2
- package/sitecustomize.py +16 -0
package/app/main.py
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
os.environ["PYTHONIOENCODING"] = "utf-8"
|
|
5
|
+
os.environ["PYTHONUTF8"] = "1"
|
|
6
|
+
if hasattr(sys.stdout, "reconfigure"):
|
|
7
|
+
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
8
|
+
if hasattr(sys.stderr, "reconfigure"):
|
|
9
|
+
sys.stderr.reconfigure(encoding="utf-8", errors="replace")
|
|
2
10
|
|
|
3
11
|
import hashlib
|
|
4
12
|
import json
|
|
@@ -7,7 +15,6 @@ import re
|
|
|
7
15
|
import time
|
|
8
16
|
from contextlib import nullcontext
|
|
9
17
|
from datetime import date, datetime, timezone
|
|
10
|
-
import sys
|
|
11
18
|
import uuid
|
|
12
19
|
from pathlib import Path
|
|
13
20
|
from typing import Any
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
os.environ["PYTHONIOENCODING"] = "utf-8"
|
|
5
|
+
os.environ["PYTHONUTF8"] = "1"
|
|
6
|
+
if hasattr(sys.stdout, "reconfigure"):
|
|
7
|
+
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
8
|
+
if hasattr(sys.stderr, "reconfigure"):
|
|
9
|
+
sys.stderr.reconfigure(encoding="utf-8", errors="replace")
|
|
2
10
|
|
|
3
11
|
import argparse
|
|
4
|
-
import os
|
|
5
12
|
import time
|
|
6
13
|
from datetime import datetime, tzinfo
|
|
7
14
|
from pathlib import Path
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
os.environ["PYTHONIOENCODING"] = "utf-8"
|
|
5
|
+
os.environ["PYTHONUTF8"] = "1"
|
|
6
|
+
if hasattr(sys.stdout, "reconfigure"):
|
|
7
|
+
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
8
|
+
if hasattr(sys.stderr, "reconfigure"):
|
|
9
|
+
sys.stderr.reconfigure(encoding="utf-8", errors="replace")
|
|
2
10
|
|
|
3
11
|
import json
|
|
4
|
-
import os
|
|
5
12
|
import queue
|
|
6
13
|
import re
|
|
7
14
|
import signal
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danhachuel/thunderbolt",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.84",
|
|
4
4
|
"description": "Thunderbolt — interface local para operação de canais faceless e motor MoneyPrinterTurbo",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "scripts/cli.mjs",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"MANUAL-INSTALACAO.md",
|
|
28
28
|
"THIRD-PARTY-NOTICES.md",
|
|
29
29
|
"requirements.txt",
|
|
30
|
+
"sitecustomize.py",
|
|
30
31
|
"package.json",
|
|
31
32
|
".streamlit/config.toml"
|
|
32
33
|
],
|
package/scripts/cli.mjs
CHANGED
|
@@ -26,12 +26,13 @@ const venvPython = platform() === "win32" ? join(venvDir, "Scripts", "python.exe
|
|
|
26
26
|
const python = process.env.THUNDERBOLT_PYTHON || process.env.HERMES_PYTHON || (existsSync(venvPython) ? venvPython : (platform() === "win32" ? "python" : "python3"));
|
|
27
27
|
const main = resolve(root, "app", "main.py");
|
|
28
28
|
const settingsPath = join(thunderboltHome, "storage", "state", "settings.json");
|
|
29
|
+
const pythonEnvironment = { ...process.env, PYTHONIOENCODING: "utf-8", PYTHONUTF8: "1" };
|
|
29
30
|
|
|
30
31
|
function run(command, commandArgs, label = "comando", environment = process.env) {
|
|
31
32
|
console.log(`Thunderbolt: a iniciar ${label}...`);
|
|
32
33
|
const result = spawnSync(command, commandArgs, {
|
|
33
34
|
stdio: "inherit",
|
|
34
|
-
env: environment,
|
|
35
|
+
env: { ...pythonEnvironment, ...environment, PYTHONIOENCODING: "utf-8", PYTHONUTF8: "1" },
|
|
35
36
|
cwd: root,
|
|
36
37
|
windowsHide: false,
|
|
37
38
|
});
|
|
@@ -47,12 +48,12 @@ function run(command, commandArgs, label = "comando", environment = process.env)
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
function pythonVersion() {
|
|
50
|
-
return spawnSync(python, ["-c", "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}')"], { encoding: "utf8" });
|
|
51
|
+
return spawnSync(python, ["-c", "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}')"], { encoding: "utf8", env: pythonEnvironment });
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
function moduleAvailable(moduleName) {
|
|
54
55
|
const code = `import importlib.util,sys; sys.exit(0 if importlib.util.find_spec(${JSON.stringify(moduleName)}) else 1)`;
|
|
55
|
-
return spawnSync(python, ["-c", code], { stdio: "ignore" }).status === 0;
|
|
56
|
+
return spawnSync(python, ["-c", code], { stdio: "ignore", env: pythonEnvironment }).status === 0;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
function configuredMoneyPrinterPath() {
|
|
@@ -152,6 +153,8 @@ ensureRuntimeStorage();
|
|
|
152
153
|
const storageDir = process.env.THUNDERBOLT_STORAGE_DIR || join(thunderboltHome, "storage");
|
|
153
154
|
const runtimeEnv = {
|
|
154
155
|
...process.env,
|
|
156
|
+
PYTHONIOENCODING: "utf-8",
|
|
157
|
+
PYTHONUTF8: "1",
|
|
155
158
|
THUNDERBOLT_STORAGE_DIR: storageDir,
|
|
156
159
|
STREAMLIT_BROWSER_GATHER_USAGE_STATS: "false",
|
|
157
160
|
STREAMLIT_SERVER_HEADLESS: "true",
|
|
@@ -254,7 +257,7 @@ function startStreamlit() {
|
|
|
254
257
|
child = spawn(python, ["-m", "streamlit", "run", main, "--server.port", String(backendPort), "--server.address", "127.0.0.1"], {
|
|
255
258
|
cwd: root,
|
|
256
259
|
stdio: "inherit",
|
|
257
|
-
env: { ...runtimeEnv, THUNDERBOLT_LAUNCHER_RESTART: "1" },
|
|
260
|
+
env: { ...runtimeEnv, PYTHONIOENCODING: "utf-8", PYTHONUTF8: "1", THUNDERBOLT_LAUNCHER_RESTART: "1" },
|
|
258
261
|
windowsHide: false,
|
|
259
262
|
});
|
|
260
263
|
child.on("error", (error) => {
|
package/scripts/install.mjs
CHANGED
|
@@ -42,6 +42,7 @@ const defaultMpt = process.env.MONEYPRINTER_PATH || join(thunderboltHome, "Money
|
|
|
42
42
|
const dependencyStatePath = join(thunderboltHome, "storage", "state", "install-state.json");
|
|
43
43
|
const forceDeps = args.includes("--force-deps");
|
|
44
44
|
const refreshMoneyPrinter = args.includes("--refresh-moneyprinter");
|
|
45
|
+
const pythonEnvironment = { ...process.env, PYTHONIOENCODING: "utf-8", PYTHONUTF8: "1" };
|
|
45
46
|
|
|
46
47
|
function legacyRoots() {
|
|
47
48
|
const userProfile = process.env.USERPROFILE || home;
|
|
@@ -63,12 +64,12 @@ function commandExists(command) {
|
|
|
63
64
|
|
|
64
65
|
function run(command, commandArgs, options = {}) {
|
|
65
66
|
console.log(`\n> ${command} ${commandArgs.join(" ")}`);
|
|
66
|
-
const result = spawnSync(command, commandArgs, { stdio: "inherit", ...options });
|
|
67
|
+
const result = spawnSync(command, commandArgs, { stdio: "inherit", env: pythonEnvironment, ...options, env: { ...pythonEnvironment, ...(options.env || {}) } });
|
|
67
68
|
if (result.status !== 0) process.exit(result.status || 1);
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
function probePython(command, commandArgs = []) {
|
|
71
|
-
const result = spawnSync(command, [...commandArgs, "-c", "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}')"], { encoding: "utf8" });
|
|
72
|
+
const result = spawnSync(command, [...commandArgs, "-c", "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}')"], { encoding: "utf8", env: pythonEnvironment });
|
|
72
73
|
if (result.status !== 0) return null;
|
|
73
74
|
const versionText = result.stdout.trim();
|
|
74
75
|
const version = versionText.split(".").map(Number);
|
package/sitecustomize.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Process-wide UTF-8 protection for Windows terminals and MobaXterm."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
os.environ["PYTHONIOENCODING"] = "utf-8"
|
|
8
|
+
os.environ["PYTHONUTF8"] = "1"
|
|
9
|
+
|
|
10
|
+
for stream_name in ("stdin", "stdout", "stderr"):
|
|
11
|
+
stream = getattr(sys, stream_name, None)
|
|
12
|
+
if stream is not None and hasattr(stream, "reconfigure"):
|
|
13
|
+
try:
|
|
14
|
+
stream.reconfigure(encoding="utf-8", errors="replace")
|
|
15
|
+
except (OSError, ValueError):
|
|
16
|
+
pass
|