diff --git a/web_interface/blueprints/api_v3/__init__.py b/web_interface/blueprints/api_v3/__init__.py index 7bebe211..8d80e0af 100644 --- a/web_interface/blueprints/api_v3/__init__.py +++ b/web_interface/blueprints/api_v3/__init__.py @@ -18,8 +18,6 @@ everything they need has to exist first. from flask import Blueprint, request, jsonify, Response import contextlib import json -import signal -import contextlib import os import re import stat @@ -1971,18 +1969,23 @@ def _mqtt_bridge_service_state() -> Dict[str, Any]: return state def _read_mqtt_bridge_config() -> Dict[str, Any]: - """Stored config overlaid on the defaults. Missing file is not an error.""" - config = dict(_MQTT_BRIDGE_DEFAULTS) - config['mqtt_password'] = None + """Stored config overlaid on the defaults. Missing file is not an error. + + Named `settings`, not `config`: this module imports a submodule called + `config` at the bottom for its route side effects, and a local of the same + name shadows it. + """ + settings = dict(_MQTT_BRIDGE_DEFAULTS) + settings['mqtt_password'] = None try: if _MQTT_BRIDGE_CONFIG.is_file(): with open(_MQTT_BRIDGE_CONFIG, encoding='utf-8') as handle: stored = json.load(handle) if isinstance(stored, dict): - config.update(stored) + settings.update(stored) except (OSError, json.JSONDecodeError) as err: logger.warning('Could not read %s: %s', _MQTT_BRIDGE_CONFIG, err) - return config + return settings def _coerce_mqtt_bridge_value(key: str, raw: Any) -> Tuple[Any, Optional[str]]: """Validate one submitted field. Returns (value, error).""" diff --git a/web_interface/blueprints/api_v3/starlark.py b/web_interface/blueprints/api_v3/starlark.py index c6276851..98c0f9c5 100644 --- a/web_interface/blueprints/api_v3/starlark.py +++ b/web_interface/blueprints/api_v3/starlark.py @@ -3,16 +3,19 @@ Routes decorate the shared `api_v3` Blueprint from ._common, so their endpoint names are unchanged by living here. """ +import signal + from web_interface.blueprints.api_v3 import ( PROJECT_ROOT, Path, _PIXLET_EDITOR_DEFAULT_PORT, _PIXLET_EDITOR_DEFAULT_TIMEOUT, _PIXLET_EDITOR_MAX_TIMEOUT, _PIXLET_EDITOR_SCRIPT, _PIXLET_EDITOR_STATE, _clear_pixlet_editor_state, _find_pixlet_binary, _install_star_file, _pixlet_editor_alive, _pixlet_editor_status, _read_pixlet_editor_state, - _standalone_render_starlark_app, _starlark_github_token, - _starlark_manifest_lock, _validate_and_sanitize_app_id, + _STARLARK_APPS_DIR, _standalone_render_starlark_app, + _starlark_github_token, _starlark_manifest_lock, + _validate_and_sanitize_app_id, _validate_starlark_app_path, _validate_timing_value, api_v3, contextlib, - describe_exception, json, jsonify, logger, os, request, shutil, signal, + describe_exception, json, jsonify, logger, os, request, shutil, subprocess, tempfile, ) import web_interface.blueprints.api_v3 as _pkg