diff options
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/daemon.py')
| -rw-r--r-- | packages/meshbay-node/src/meshbay_node/daemon.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/daemon.py b/packages/meshbay-node/src/meshbay_node/daemon.py index d616b0c..72f7fa4 100644 --- a/packages/meshbay-node/src/meshbay_node/daemon.py +++ b/packages/meshbay-node/src/meshbay_node/daemon.py @@ -219,7 +219,7 @@ class NodeDaemon: # should ever copy a token out of a log or a terminal. self._config.data_dir.mkdir(parents=True, exist_ok=True) self._ui_token_file = self._config.data_dir / "ui-token" - self._ui_token_file.write_text(ui_token) + self._ui_token_file.write_text(ui_token, encoding="utf-8", newline="\n") chmod_private(self._ui_token_file) from meshbay_node.ui import create_ui_app ui_app = create_ui_app(self._state) @@ -1526,7 +1526,7 @@ def _daemon_api(cfg: Config, path: str, method: str = "GET", sep = "&" if "?" in path else "?" url = (f"http://127.0.0.1:{cfg.node.ui_port}{path}" - f"{sep}t={token_file.read_text().strip()}") + f"{sep}t={token_file.read_text(encoding="utf-8").strip()}") try: data = _json.dumps(body).encode() if body is not None else None req = urllib.request.Request( @@ -1708,7 +1708,7 @@ def main() -> None: sys.exit(1) if cfg_path.exists(): - existing = cfg_path.read_text() + existing = cfg_path.read_text(encoding="utf-8") import re as _re m = _re.search(r'username\s*=\s*"([^"]*)"', existing) existing_user = m.group(1) if m else "" @@ -1721,7 +1721,7 @@ def main() -> None: r'(username\s*=\s*)"[^"]*"', rf'\1"{username}"', existing) updated = _re.sub( r'(url\s*=\s*)"[^"]*"', rf'\1"{hub_url}"', updated, count=1) - cfg_path.write_text(updated) + cfg_path.write_text(updated, encoding="utf-8", newline="\n") print(f"Config updated: username={username}, hub={hub_url}") else: print(f"Config already exists: {cfg_path}") @@ -1741,7 +1741,7 @@ def main() -> None: f'unlock_file = "{unlock_file}"', "", ] - cfg_path.write_text("\n".join(toml_lines) + "\n") + cfg_path.write_text("\n".join(toml_lines) + "\n", encoding="utf-8", newline="\n") chmod_private(cfg_path) print(f"Config written to {cfg_path}") @@ -1749,7 +1749,7 @@ def main() -> None: if not unlock_file.exists(): import secrets key = secrets.token_urlsafe(32) - unlock_file.write_text(key + "\n") + unlock_file.write_text(key + "\n", encoding="utf-8", newline="\n") chmod_private(unlock_file) print(f"Unlock key created: {unlock_file}") @@ -1815,7 +1815,7 @@ def main() -> None: if token_file.exists(): try: cfg = Config(config_dir_ / "node.toml") - tok = token_file.read_text().strip() + tok = token_file.read_text(encoding="utf-8").strip() url = (f"http://127.0.0.1:{cfg.node.ui_port}" f"/api/unlink?t={tok}") req = urllib.request.Request(url, method="DELETE") @@ -1864,7 +1864,7 @@ def main() -> None: if token_file.exists(): try: url = (f"http://127.0.0.1:{cfg.node.ui_port}" - f"/api/status?t={token_file.read_text().strip()}") + f"/api/status?t={token_file.read_text(encoding="utf-8").strip()}") with urllib.request.urlopen(url, timeout=3) as r: live = _json.loads(r.read()) except Exception: |