rename run_no_output to run_no_stdout
we want stderr for some nix commands.
This commit is contained in:
@@ -5,7 +5,7 @@ from pathlib import Path
|
||||
from typing import Any, Literal
|
||||
|
||||
from clan_cli.errors import ClanError
|
||||
from clan_cli.nix import nix_shell, run_no_output
|
||||
from clan_cli.nix import nix_shell, run_no_stdout
|
||||
|
||||
from . import API
|
||||
|
||||
@@ -154,7 +154,7 @@ def show_block_devices(options: BlockDeviceOptions) -> Blockdevices:
|
||||
"PATH,NAME,RM,SIZE,RO,MOUNTPOINTS,TYPE,ID-LINK",
|
||||
],
|
||||
)
|
||||
proc = run_no_output(cmd, needs_user_terminal=True)
|
||||
proc = run_no_stdout(cmd, needs_user_terminal=True)
|
||||
res = proc.stdout.strip()
|
||||
|
||||
blk_info: dict[str, Any] = json.loads(res)
|
||||
|
||||
@@ -2,7 +2,7 @@ import argparse
|
||||
import re
|
||||
from dataclasses import dataclass
|
||||
|
||||
from clan_cli.cmd import run_no_output
|
||||
from clan_cli.cmd import run_no_stdout
|
||||
from clan_cli.nix import nix_shell
|
||||
|
||||
from . import API
|
||||
@@ -100,7 +100,7 @@ def show_mdns() -> DNSInfo:
|
||||
"--terminate",
|
||||
],
|
||||
)
|
||||
proc = run_no_output(cmd)
|
||||
proc = run_no_stdout(cmd)
|
||||
data = parse_avahi_output(proc.stdout)
|
||||
|
||||
return data
|
||||
|
||||
@@ -5,7 +5,7 @@ from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any, TypedDict, get_args, get_type_hints
|
||||
|
||||
from clan_cli.cmd import run_no_output
|
||||
from clan_cli.cmd import run_no_stdout
|
||||
from clan_cli.errors import ClanCmdError, ClanError
|
||||
from clan_cli.inventory import Inventory, load_inventory_json, set_inventory
|
||||
from clan_cli.inventory.classes import Service
|
||||
@@ -164,7 +164,7 @@ def get_modules(base_path: str) -> dict[str, str]:
|
||||
]
|
||||
)
|
||||
try:
|
||||
proc = run_no_output(cmd)
|
||||
proc = run_no_stdout(cmd)
|
||||
res = proc.stdout.strip()
|
||||
except ClanCmdError as e:
|
||||
msg = "clanInternals might not have inventory.modules attributes"
|
||||
@@ -185,7 +185,7 @@ def get_module_interface(base_path: str, module_name: str) -> dict[str, Any]:
|
||||
"""
|
||||
cmd = nix_eval([f"{base_path}#clanInternals.moduleSchemas.{module_name}", "--json"])
|
||||
try:
|
||||
proc = run_no_output(cmd)
|
||||
proc = run_no_stdout(cmd)
|
||||
res = proc.stdout.strip()
|
||||
except ClanCmdError as e:
|
||||
msg = "clanInternals might not have moduleSchemas attributes"
|
||||
|
||||
@@ -5,7 +5,7 @@ from pathlib import Path
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from clan_cli.api import API
|
||||
from clan_cli.cmd import run_no_output
|
||||
from clan_cli.cmd import run_no_stdout
|
||||
from clan_cli.errors import ClanCmdError, ClanError
|
||||
from clan_cli.inventory import Meta
|
||||
from clan_cli.nix import nix_eval
|
||||
@@ -24,7 +24,7 @@ def show_clan_meta(uri: str | Path) -> Meta:
|
||||
res = "{}"
|
||||
|
||||
try:
|
||||
proc = run_no_output(cmd)
|
||||
proc = run_no_stdout(cmd)
|
||||
res = proc.stdout.strip()
|
||||
except ClanCmdError as e:
|
||||
msg = "Evaluation failed on meta attribute"
|
||||
|
||||
@@ -338,12 +338,12 @@ def run(
|
||||
return cmd_out
|
||||
|
||||
|
||||
def run_no_output(
|
||||
def run_no_stdout(
|
||||
cmd: list[str],
|
||||
*,
|
||||
env: dict[str, str] | None = None,
|
||||
cwd: Path | None = None,
|
||||
log: Log = Log.NONE,
|
||||
log: Log = Log.STDERR,
|
||||
prefix: str | None = None,
|
||||
check: bool = True,
|
||||
error_msg: str | None = None,
|
||||
|
||||
@@ -18,7 +18,7 @@ from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from clan_cli.api import API, dataclass_to_dict, from_dict
|
||||
from clan_cli.cmd import run_no_output
|
||||
from clan_cli.cmd import run_no_stdout
|
||||
from clan_cli.errors import ClanCmdError, ClanError
|
||||
from clan_cli.git import commit_file
|
||||
from clan_cli.nix import nix_eval
|
||||
@@ -78,7 +78,7 @@ def load_inventory_eval(flake_dir: str | Path) -> Inventory:
|
||||
]
|
||||
)
|
||||
|
||||
proc = run_no_output(cmd)
|
||||
proc = run_no_stdout(cmd)
|
||||
|
||||
try:
|
||||
res = proc.stdout.strip()
|
||||
|
||||
@@ -7,7 +7,7 @@ from pathlib import Path
|
||||
|
||||
from clan_cli.api import API
|
||||
from clan_cli.clan_uri import FlakeId
|
||||
from clan_cli.cmd import RunOpts, run, run_no_output
|
||||
from clan_cli.cmd import RunOpts, run, run_no_stdout
|
||||
from clan_cli.completions import add_dynamic_completer, complete_machines
|
||||
from clan_cli.dirs import specific_machine_dir
|
||||
from clan_cli.errors import ClanCmdError, ClanError
|
||||
@@ -71,7 +71,7 @@ def show_machine_deployment_target(clan_dir: Path, machine_name: str) -> str | N
|
||||
"--json",
|
||||
]
|
||||
)
|
||||
proc = run_no_output(cmd)
|
||||
proc = run_no_stdout(cmd)
|
||||
res = proc.stdout.strip()
|
||||
|
||||
target_host = json.loads(res)
|
||||
@@ -93,7 +93,7 @@ def show_machine_hardware_platform(clan_dir: Path, machine_name: str) -> str | N
|
||||
"--json",
|
||||
]
|
||||
)
|
||||
proc = run_no_output(cmd)
|
||||
proc = run_no_stdout(cmd)
|
||||
res = proc.stdout.strip()
|
||||
|
||||
host_platform = json.loads(res)
|
||||
|
||||
@@ -7,7 +7,7 @@ from typing import Literal
|
||||
|
||||
from clan_cli.api import API
|
||||
from clan_cli.api.modules import parse_frontmatter
|
||||
from clan_cli.cmd import run_no_output
|
||||
from clan_cli.cmd import run_no_stdout
|
||||
from clan_cli.completions import add_dynamic_completer, complete_tags
|
||||
from clan_cli.dirs import specific_machine_dir
|
||||
from clan_cli.errors import ClanCmdError, ClanError
|
||||
@@ -88,7 +88,7 @@ def list_nixos_machines(flake_url: str | Path) -> list[str]:
|
||||
"--json",
|
||||
]
|
||||
)
|
||||
proc = run_no_output(cmd)
|
||||
proc = run_no_stdout(cmd)
|
||||
|
||||
try:
|
||||
res = proc.stdout.strip()
|
||||
@@ -142,7 +142,7 @@ def check_machine_online(
|
||||
],
|
||||
)
|
||||
try:
|
||||
proc = run_no_output(cmd, needs_user_terminal=True)
|
||||
proc = run_no_stdout(cmd, needs_user_terminal=True)
|
||||
if proc.returncode != 0:
|
||||
return "Offline"
|
||||
except ClanCmdError:
|
||||
|
||||
@@ -9,7 +9,7 @@ from tempfile import NamedTemporaryFile
|
||||
from typing import TYPE_CHECKING, Any, Literal
|
||||
|
||||
from clan_cli.clan_uri import FlakeId
|
||||
from clan_cli.cmd import run_no_output
|
||||
from clan_cli.cmd import run_no_stdout
|
||||
from clan_cli.errors import ClanError
|
||||
from clan_cli.facts import public_modules as facts_public_modules
|
||||
from clan_cli.facts import secret_modules as facts_secret_modules
|
||||
@@ -70,7 +70,7 @@ class Machine:
|
||||
attr = f'(builtins.getFlake "{self.flake}").nixosConfigurations.{self.name}.pkgs.hostPlatform.system'
|
||||
output = self._eval_cache.get(attr)
|
||||
if output is None:
|
||||
output = run_no_output(
|
||||
output = run_no_stdout(
|
||||
nix_eval(["--impure", "--expr", attr])
|
||||
).stdout.strip()
|
||||
self._eval_cache[attr] = output
|
||||
@@ -238,7 +238,7 @@ class Machine:
|
||||
config_json.flush()
|
||||
|
||||
file_info = json.loads(
|
||||
run_no_output(
|
||||
run_no_stdout(
|
||||
nix_eval(
|
||||
[
|
||||
"--impure",
|
||||
@@ -283,9 +283,9 @@ class Machine:
|
||||
args += nix_options + self.nix_options
|
||||
|
||||
if method == "eval":
|
||||
output = run_no_output(nix_eval(args)).stdout.strip()
|
||||
output = run_no_stdout(nix_eval(args)).stdout.strip()
|
||||
return output
|
||||
return Path(run_no_output(nix_build(args)).stdout.strip())
|
||||
return Path(run_no_stdout(nix_build(args)).stdout.strip())
|
||||
|
||||
def eval_nix(
|
||||
self,
|
||||
|
||||
@@ -4,7 +4,7 @@ import tempfile
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from clan_cli.cmd import run, run_no_output
|
||||
from clan_cli.cmd import run, run_no_stdout
|
||||
from clan_cli.dirs import nixpkgs_flake, nixpkgs_source
|
||||
from clan_cli.errors import ClanError
|
||||
|
||||
@@ -63,7 +63,7 @@ def nix_add_to_gcroots(nix_path: Path, dest: Path) -> None:
|
||||
|
||||
def nix_config() -> dict[str, Any]:
|
||||
cmd = nix_command(["show-config", "--json"])
|
||||
proc = run_no_output(cmd)
|
||||
proc = run_no_stdout(cmd)
|
||||
data = json.loads(proc.stdout)
|
||||
config = {}
|
||||
for key, value in data.items():
|
||||
|
||||
@@ -3,7 +3,7 @@ import json
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from clan_cli.cmd import run_no_output
|
||||
from clan_cli.cmd import run_no_stdout
|
||||
from clan_cli.completions import (
|
||||
add_dynamic_completer,
|
||||
complete_machines,
|
||||
@@ -31,7 +31,7 @@ def list_state_folders(machine: str, service: None | str = None) -> None:
|
||||
res = "{}"
|
||||
|
||||
try:
|
||||
proc = run_no_output(cmd)
|
||||
proc = run_no_stdout(cmd)
|
||||
res = proc.stdout.strip()
|
||||
except ClanCmdError as e:
|
||||
msg = "Clan might not have meta attributes"
|
||||
|
||||
@@ -2,7 +2,7 @@ import json
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from clan_cli.cmd import run_no_output
|
||||
from clan_cli.cmd import run_no_stdout
|
||||
from clan_cli.errors import ClanError
|
||||
from clan_cli.nix import nix_eval
|
||||
|
||||
@@ -18,7 +18,7 @@ def list_tagged_machines(flake_url: str | Path) -> dict[str, Any]:
|
||||
"--json",
|
||||
]
|
||||
)
|
||||
proc = run_no_output(cmd)
|
||||
proc = run_no_stdout(cmd)
|
||||
|
||||
try:
|
||||
res = proc.stdout.strip()
|
||||
|
||||
@@ -12,7 +12,7 @@ from clan_cli.inventory import (
|
||||
set_inventory,
|
||||
)
|
||||
from clan_cli.machines.create import CreateOptions, create_machine
|
||||
from clan_cli.nix import nix_eval, run_no_output
|
||||
from clan_cli.nix import nix_eval, run_no_stdout
|
||||
from fixtures_flakes import FlakeForTest
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -97,7 +97,7 @@ def test_add_module_to_inventory(
|
||||
"--json",
|
||||
]
|
||||
)
|
||||
proc = run_no_output(cmd)
|
||||
proc = run_no_stdout(cmd)
|
||||
res = json.loads(proc.stdout.strip())
|
||||
|
||||
assert res["machine1"]["authorizedKeys"] == [ssh_key]
|
||||
|
||||
Reference in New Issue
Block a user