aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node')
-rw-r--r--packages/meshbay-node/src/meshbay_node/daemon.py7
-rw-r--r--packages/meshbay-node/src/meshbay_node/ops.py8
-rw-r--r--packages/meshbay-node/src/meshbay_node/platform.py18
3 files changed, 28 insertions, 5 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/daemon.py b/packages/meshbay-node/src/meshbay_node/daemon.py
index 72f7fa4..6bc3bef 100644
--- a/packages/meshbay-node/src/meshbay_node/daemon.py
+++ b/packages/meshbay-node/src/meshbay_node/daemon.py
@@ -1634,7 +1634,8 @@ def _systemctl_user(verb: str, unit: str, *, not_running_hint: str,
def main() -> None:
import argparse
- from meshbay_node.platform import use_compatible_event_loop
+ from meshbay_node.platform import force_utf8_stdio, use_compatible_event_loop
+ force_utf8_stdio()
use_compatible_event_loop()
parser = argparse.ArgumentParser(description="MeshBay Node daemon")
@@ -1738,7 +1739,9 @@ def main() -> None:
"ui_port = 18000",
"",
"[keystore]",
- f'unlock_file = "{unlock_file}"',
+ # Forward slashes: a Windows path in a TOML basic string is a
+ # parse error (`\U`, `\a`, ... are escape sequences).
+ f'unlock_file = "{unlock_file.as_posix()}"',
"",
]
cfg_path.write_text("\n".join(toml_lines) + "\n", encoding="utf-8", newline="\n")
diff --git a/packages/meshbay-node/src/meshbay_node/ops.py b/packages/meshbay-node/src/meshbay_node/ops.py
index 40de755..4c20c2a 100644
--- a/packages/meshbay-node/src/meshbay_node/ops.py
+++ b/packages/meshbay-node/src/meshbay_node/ops.py
@@ -447,9 +447,11 @@ async def attach_group(state: dict, name: str, shared_dir: str,
upload_path.mkdir(parents=True, exist_ok=True)
except OSError as e:
raise OpError(f"Cannot create {upload_path}: {e}") from e
- block += f'upload_dir = "{upload_path}"\n'
+ block += f'upload_dir = "{upload_path.as_posix()}"\n'
block += (f'\n [[groups.roots]]\n'
- f' path = "{path}"\n')
+ # Forward slashes: a Windows path in a TOML basic string is a
+ # parse error (`\U`, `\a`, ... are escapes). pathlib reads `/`.
+ f' path = "{path.as_posix()}"\n')
if not separate_upload:
block += f' upload = true\n'
try:
@@ -667,7 +669,7 @@ async def add_root(state: dict, group_id: str, path: str, *,
raise OpError(f"Cannot create {added.path}: {e}") from e
conf_path = Path(state.get("config_path") or DEFAULT_CONFIG_PATH)
- root_block = f' [[groups.roots]]\n path = "{added.path}"'
+ root_block = f' [[groups.roots]]\n path = "{added.path.as_posix()}"'
if name:
root_block += f'\n name = "{added.name}"'
if kind != "generic":
diff --git a/packages/meshbay-node/src/meshbay_node/platform.py b/packages/meshbay-node/src/meshbay_node/platform.py
index 4bd8e35..80aa6ae 100644
--- a/packages/meshbay-node/src/meshbay_node/platform.py
+++ b/packages/meshbay-node/src/meshbay_node/platform.py
@@ -6,6 +6,24 @@ import shutil
import sys
from pathlib import Path
+# ── Console ──────────────────────────────────────────────────────────────────
+
+
+def force_utf8_stdio() -> None:
+ """
+ Make stdout/stderr UTF-8. A Windows console is cp1252 by default, so any
+ ``print()`` carrying a character outside it — the ``->`` arrows and em
+ dashes the CLI help and messages are full of — raises UnicodeEncodeError
+ and takes the command down with it. No effect where the streams are
+ already UTF-8 or cannot be reconfigured.
+ """
+ for stream in (sys.stdout, sys.stderr):
+ try:
+ stream.reconfigure(encoding="utf-8")
+ except (AttributeError, ValueError, OSError):
+ pass
+
+
# ── Event loop ───────────────────────────────────────────────────────────────