checkpoint: into main from release/2.4.3 @ 7b777e7db7 (#18401)

Source hash: 7b777e7db7
Remaining commits: 1
This commit is contained in:
Starttoaster
2024-08-06 15:25:40 -07:00
committed by GitHub
3 changed files with 26 additions and 3 deletions
+16 -1
View File
@@ -1,5 +1,6 @@
from __future__ import annotations
import sys
from pathlib import Path
from typing import Any, Dict, Optional
@@ -9,7 +10,7 @@ from click.testing import CliRunner
from pytest_mock import MockerFixture
from chia.cmds.chia import cli
from chia.cmds.start_funcs import create_start_daemon_connection
from chia.cmds.start_funcs import create_start_daemon_connection, launch_start_daemon
@pytest.mark.anyio
@@ -52,6 +53,20 @@ async def test_daemon(
assert not captured.out.endswith("Skipping to unlock keyring\n")
@pytest.mark.anyio
def test_launch_start_daemon(tmp_path: Path) -> None:
sys.argv[0] = "not-exist"
with pytest.raises(FileNotFoundError):
launch_start_daemon(tmp_path)
helper: Path = Path(sys.executable)
sys.argv[0] = str(helper.parent) + "/chia"
process = launch_start_daemon(tmp_path)
assert process is not None
process.kill()
process.wait()
def test_start_daemon(tmp_path: Path, empty_keyring: Any, mocker: MockerFixture) -> None:
class DummyDaemon:
@staticmethod
+7 -1
View File
@@ -2,6 +2,7 @@ from __future__ import annotations
import asyncio
import os
import shutil
import subprocess
import sys
from concurrent.futures import ThreadPoolExecutor
@@ -21,8 +22,13 @@ def launch_start_daemon(root_path: Path) -> subprocess.Popen:
if sys.platform == "win32":
creationflags = subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.CREATE_NO_WINDOW
path_helper: Path = Path(sys.argv[0])
cmd_to_execute = shutil.which(cmd=path_helper.name, path=path_helper.parent)
if cmd_to_execute is None:
cmd_to_execute = sys.argv[0]
process = subprocess.Popen(
[sys.argv[0], "run_daemon", "--wait-for-unlock"],
[cmd_to_execute, "run_daemon", "--wait-for-unlock"],
encoding="utf-8",
stdout=subprocess.PIPE,
creationflags=creationflags,
+3 -1
View File
@@ -5,6 +5,7 @@ import dataclasses
import json
import logging
import os
import shutil
import signal
import ssl
import subprocess
@@ -112,7 +113,8 @@ else:
application_path = os.path.dirname(__file__)
def executable_for_service(service_name: str) -> str:
return service_name
cmd_to_exec = shutil.which(service_name)
return cmd_to_exec if cmd_to_exec is not None else service_name
async def ping() -> Dict[str, Any]: