mirror of
https://github.com/esphome/esphome.git
synced 2026-09-17 10:08:40 +00:00
[dashboard] Use sys.executable for dashboard subprocess commands (#14698)
Co-authored-by: Jonathan Swoboda <swoboda1337@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Jonathan Swoboda
Claude Opus 4.6
pre-commit-ci-lite[bot]
parent
03c0ce704b
commit
04bcd9f56b
+7
-6
@@ -74,6 +74,8 @@ from esphome.util import (
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ESPHOME_COMMAND = [sys.executable, "-m", "esphome"]
|
||||
|
||||
# Maximum buffer size for serial log reading to prevent unbounded memory growth
|
||||
SERIAL_BUFFER_MAX_SIZE = 65536
|
||||
|
||||
@@ -1307,9 +1309,8 @@ def command_update_all(args: ArgsProtocol) -> int | None:
|
||||
files = list_yaml_files(args.configuration)
|
||||
|
||||
def build_command(f):
|
||||
if CORE.dashboard:
|
||||
return ["esphome", "--dashboard", "run", f, "--no-logs", "--device", "OTA"]
|
||||
return ["esphome", "run", f, "--no-logs", "--device", "OTA"]
|
||||
dashboard = ["--dashboard"] if CORE.dashboard else []
|
||||
return [*ESPHOME_COMMAND, *dashboard, "run", f, "--no-logs", "--device", "OTA"]
|
||||
|
||||
return run_multiple_configs(files, build_command)
|
||||
|
||||
@@ -1458,7 +1459,7 @@ def command_rename(args: ArgsProtocol, config: ConfigType) -> int | None:
|
||||
|
||||
new_path.write_text(new_raw, encoding="utf-8")
|
||||
|
||||
rc = run_external_process("esphome", "config", str(new_path))
|
||||
rc = run_external_process(*ESPHOME_COMMAND, "config", str(new_path))
|
||||
if rc != 0:
|
||||
print(color(AnsiFore.BOLD_RED, "Rename failed. Reverting changes."))
|
||||
new_path.unlink()
|
||||
@@ -1476,7 +1477,7 @@ def command_rename(args: ArgsProtocol, config: ConfigType) -> int | None:
|
||||
cli_args.insert(0, "--dashboard")
|
||||
|
||||
try:
|
||||
rc = run_external_process("esphome", *cli_args)
|
||||
rc = run_external_process(*ESPHOME_COMMAND, *cli_args)
|
||||
except KeyboardInterrupt:
|
||||
rc = 1
|
||||
if rc != 0:
|
||||
@@ -1873,7 +1874,7 @@ def run_esphome(argv):
|
||||
# argv[0] is the program path, skip it since we prefix with "esphome"
|
||||
def build_command(f):
|
||||
return (
|
||||
["esphome"]
|
||||
[*ESPHOME_COMMAND]
|
||||
+ [arg for arg in argv[1:] if arg not in args.configuration]
|
||||
+ [str(f)]
|
||||
)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
from esphome.enum import StrEnum
|
||||
|
||||
|
||||
@@ -26,4 +28,5 @@ MAX_EXECUTOR_WORKERS = 48
|
||||
|
||||
SENTINEL = object()
|
||||
|
||||
DASHBOARD_COMMAND = ["esphome", "--dashboard"]
|
||||
ESPHOME_COMMAND = [sys.executable, "-m", "esphome"]
|
||||
DASHBOARD_COMMAND = [*ESPHOME_COMMAND, "--dashboard"]
|
||||
|
||||
@@ -52,7 +52,7 @@ from esphome.util import get_serial_ports, shlex_quote
|
||||
from esphome.yaml_util import FastestAvailableSafeLoader
|
||||
|
||||
from ..helpers import write_file
|
||||
from .const import DASHBOARD_COMMAND, DashboardEvent
|
||||
from .const import DASHBOARD_COMMAND, ESPHOME_COMMAND, DashboardEvent
|
||||
from .core import DASHBOARD, ESPHomeDashboard, Event
|
||||
from .entries import UNKNOWN_STATE, DashboardEntry, entry_state_to_bool
|
||||
from .models import build_device_list_response
|
||||
@@ -1079,7 +1079,7 @@ class DownloadBinaryRequestHandler(BaseHandler):
|
||||
return
|
||||
|
||||
if not path.is_file():
|
||||
args = ["esphome", "idedata", settings.rel_path(configuration)]
|
||||
args = [*ESPHOME_COMMAND, "idedata", settings.rel_path(configuration)]
|
||||
rc, stdout, _ = await async_run_system_command(args)
|
||||
|
||||
if rc != 0:
|
||||
@@ -1462,7 +1462,7 @@ class JsonConfigRequestHandler(BaseHandler):
|
||||
self.send_error(404)
|
||||
return
|
||||
|
||||
args = ["esphome", "config", str(filename), "--show-secrets"]
|
||||
args = [*ESPHOME_COMMAND, "config", str(filename), "--show-secrets"]
|
||||
|
||||
rc, stdout, stderr = await async_run_system_command(args)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user