RET504: fix
This commit is contained in:
@@ -39,8 +39,7 @@ def generate_ula_prefix(instance_name: str) -> ipaddress.IPv6Network:
|
|||||||
prefix = f"fd{prefix_bits:08x}"
|
prefix = f"fd{prefix_bits:08x}"
|
||||||
prefix_formatted = f"{prefix[:4]}:{prefix[4:8]}::/40"
|
prefix_formatted = f"{prefix[:4]}:{prefix[4:8]}::/40"
|
||||||
|
|
||||||
network = ipaddress.IPv6Network(prefix_formatted)
|
return ipaddress.IPv6Network(prefix_formatted)
|
||||||
return network
|
|
||||||
|
|
||||||
|
|
||||||
def generate_controller_subnet(
|
def generate_controller_subnet(
|
||||||
@@ -60,9 +59,7 @@ def generate_controller_subnet(
|
|||||||
# The controller subnet is at base_prefix:controller_id::/56
|
# The controller subnet is at base_prefix:controller_id::/56
|
||||||
base_int = int(base_network.network_address)
|
base_int = int(base_network.network_address)
|
||||||
controller_subnet_int = base_int | (controller_id << (128 - 56))
|
controller_subnet_int = base_int | (controller_id << (128 - 56))
|
||||||
controller_subnet = ipaddress.IPv6Network((controller_subnet_int, 56))
|
return ipaddress.IPv6Network((controller_subnet_int, 56))
|
||||||
|
|
||||||
return controller_subnet
|
|
||||||
|
|
||||||
|
|
||||||
def generate_peer_suffix(peer_name: str) -> str:
|
def generate_peer_suffix(peer_name: str) -> str:
|
||||||
@@ -76,8 +73,7 @@ def generate_peer_suffix(peer_name: str) -> str:
|
|||||||
suffix_bits = h[:16]
|
suffix_bits = h[:16]
|
||||||
|
|
||||||
# Format as IPv6 suffix without leading colon
|
# Format as IPv6 suffix without leading colon
|
||||||
suffix = f"{suffix_bits[0:4]}:{suffix_bits[4:8]}:{suffix_bits[8:12]}:{suffix_bits[12:16]}"
|
return f"{suffix_bits[0:4]}:{suffix_bits[4:8]}:{suffix_bits[8:12]}:{suffix_bits[12:16]}"
|
||||||
return suffix
|
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
|
|||||||
@@ -551,8 +551,7 @@ def options_docs_from_tree(
|
|||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
md = render_tree(root)
|
return render_tree(root)
|
||||||
return md
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -324,14 +324,13 @@ class Machine:
|
|||||||
# Always run command with shell opts
|
# Always run command with shell opts
|
||||||
command = f"set -eo pipefail; source /etc/profile; set -xu; {command}"
|
command = f"set -eo pipefail; source /etc/profile; set -xu; {command}"
|
||||||
|
|
||||||
proc = subprocess.run(
|
return subprocess.run(
|
||||||
self.nsenter_command(command),
|
self.nsenter_command(command),
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
check=False,
|
check=False,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
text=True,
|
text=True,
|
||||||
)
|
)
|
||||||
return proc
|
|
||||||
|
|
||||||
def nested(
|
def nested(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@@ -73,8 +73,7 @@ def complete_machines(
|
|||||||
if thread.is_alive():
|
if thread.is_alive():
|
||||||
return iter([])
|
return iter([])
|
||||||
|
|
||||||
machines_dict = dict.fromkeys(machines, "machine")
|
return dict.fromkeys(machines, "machine")
|
||||||
return machines_dict
|
|
||||||
|
|
||||||
|
|
||||||
def complete_services_for_machine(
|
def complete_services_for_machine(
|
||||||
@@ -118,8 +117,7 @@ def complete_services_for_machine(
|
|||||||
if thread.is_alive():
|
if thread.is_alive():
|
||||||
return iter([])
|
return iter([])
|
||||||
|
|
||||||
services_dict = dict.fromkeys(services, "service")
|
return dict.fromkeys(services, "service")
|
||||||
return services_dict
|
|
||||||
|
|
||||||
|
|
||||||
def complete_backup_providers_for_machine(
|
def complete_backup_providers_for_machine(
|
||||||
@@ -162,8 +160,7 @@ def complete_backup_providers_for_machine(
|
|||||||
if thread.is_alive():
|
if thread.is_alive():
|
||||||
return iter([])
|
return iter([])
|
||||||
|
|
||||||
providers_dict = dict.fromkeys(providers, "provider")
|
return dict.fromkeys(providers, "provider")
|
||||||
return providers_dict
|
|
||||||
|
|
||||||
|
|
||||||
def complete_state_services_for_machine(
|
def complete_state_services_for_machine(
|
||||||
@@ -206,8 +203,7 @@ def complete_state_services_for_machine(
|
|||||||
if thread.is_alive():
|
if thread.is_alive():
|
||||||
return iter([])
|
return iter([])
|
||||||
|
|
||||||
providers_dict = dict.fromkeys(providers, "service")
|
return dict.fromkeys(providers, "service")
|
||||||
return providers_dict
|
|
||||||
|
|
||||||
|
|
||||||
def complete_secrets(
|
def complete_secrets(
|
||||||
@@ -225,8 +221,7 @@ def complete_secrets(
|
|||||||
|
|
||||||
secrets = list_secrets(Flake(flake).path)
|
secrets = list_secrets(Flake(flake).path)
|
||||||
|
|
||||||
secrets_dict = dict.fromkeys(secrets, "secret")
|
return dict.fromkeys(secrets, "secret")
|
||||||
return secrets_dict
|
|
||||||
|
|
||||||
|
|
||||||
def complete_users(
|
def complete_users(
|
||||||
@@ -244,8 +239,7 @@ def complete_users(
|
|||||||
|
|
||||||
users = list_users(Path(flake))
|
users = list_users(Path(flake))
|
||||||
|
|
||||||
users_dict = dict.fromkeys(users, "user")
|
return dict.fromkeys(users, "user")
|
||||||
return users_dict
|
|
||||||
|
|
||||||
|
|
||||||
def complete_groups(
|
def complete_groups(
|
||||||
@@ -264,8 +258,7 @@ def complete_groups(
|
|||||||
groups_list = list_groups(Path(flake))
|
groups_list = list_groups(Path(flake))
|
||||||
groups = [group.name for group in groups_list]
|
groups = [group.name for group in groups_list]
|
||||||
|
|
||||||
groups_dict = dict.fromkeys(groups, "group")
|
return dict.fromkeys(groups, "group")
|
||||||
return groups_dict
|
|
||||||
|
|
||||||
|
|
||||||
def complete_templates_disko(
|
def complete_templates_disko(
|
||||||
@@ -285,8 +278,7 @@ def complete_templates_disko(
|
|||||||
disko_template_list = list_all_templates.builtins.get("disko")
|
disko_template_list = list_all_templates.builtins.get("disko")
|
||||||
if disko_template_list:
|
if disko_template_list:
|
||||||
disko_templates = list(disko_template_list)
|
disko_templates = list(disko_template_list)
|
||||||
disko_dict = dict.fromkeys(disko_templates, "disko")
|
return dict.fromkeys(disko_templates, "disko")
|
||||||
return disko_dict
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
@@ -307,8 +299,7 @@ def complete_templates_clan(
|
|||||||
clan_template_list = list_all_templates.builtins.get("clan")
|
clan_template_list = list_all_templates.builtins.get("clan")
|
||||||
if clan_template_list:
|
if clan_template_list:
|
||||||
clan_templates = list(clan_template_list)
|
clan_templates = list(clan_template_list)
|
||||||
clan_dict = dict.fromkeys(clan_templates, "clan")
|
return dict.fromkeys(clan_templates, "clan")
|
||||||
return clan_dict
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
@@ -350,8 +341,7 @@ def complete_vars_for_machine(
|
|||||||
except (OSError, PermissionError):
|
except (OSError, PermissionError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
vars_dict = dict.fromkeys(vars_list, "var")
|
return dict.fromkeys(vars_list, "var")
|
||||||
return vars_dict
|
|
||||||
|
|
||||||
|
|
||||||
def complete_target_host(
|
def complete_target_host(
|
||||||
@@ -392,8 +382,7 @@ def complete_target_host(
|
|||||||
if thread.is_alive():
|
if thread.is_alive():
|
||||||
return iter([])
|
return iter([])
|
||||||
|
|
||||||
providers_dict = dict.fromkeys(target_hosts, "target_host")
|
return dict.fromkeys(target_hosts, "target_host")
|
||||||
return providers_dict
|
|
||||||
|
|
||||||
|
|
||||||
def complete_tags(
|
def complete_tags(
|
||||||
@@ -462,8 +451,7 @@ def complete_tags(
|
|||||||
if any(thread.is_alive() for thread in threads):
|
if any(thread.is_alive() for thread in threads):
|
||||||
return iter([])
|
return iter([])
|
||||||
|
|
||||||
providers_dict = dict.fromkeys(tags, "tag")
|
return dict.fromkeys(tags, "tag")
|
||||||
return providers_dict
|
|
||||||
|
|
||||||
|
|
||||||
def add_dynamic_completer(
|
def add_dynamic_completer(
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from clan_lib.ssh.remote import Remote
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def hosts(sshd: Sshd) -> list[Remote]:
|
def hosts(sshd: Sshd) -> list[Remote]:
|
||||||
login = pwd.getpwuid(os.getuid()).pw_name
|
login = pwd.getpwuid(os.getuid()).pw_name
|
||||||
group = [
|
return [
|
||||||
Remote(
|
Remote(
|
||||||
address="127.0.0.1",
|
address="127.0.0.1",
|
||||||
port=sshd.port,
|
port=sshd.port,
|
||||||
@@ -20,5 +20,3 @@ def hosts(sshd: Sshd) -> list[Remote]:
|
|||||||
command_prefix="local_test",
|
command_prefix="local_test",
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
return group
|
|
||||||
|
|||||||
@@ -164,13 +164,12 @@ class SecretStore(StoreBase):
|
|||||||
msg = f"file {file_name} was not found"
|
msg = f"file {file_name} was not found"
|
||||||
raise ClanError(msg)
|
raise ClanError(msg)
|
||||||
if outdated:
|
if outdated:
|
||||||
msg = (
|
return (
|
||||||
"The local state of some secret vars is inconsistent and needs to be updated.\n"
|
"The local state of some secret vars is inconsistent and needs to be updated.\n"
|
||||||
f"Run 'clan vars fix {machine}' to apply the necessary changes."
|
f"Run 'clan vars fix {machine}' to apply the necessary changes."
|
||||||
"Problems to fix:\n"
|
"Problems to fix:\n"
|
||||||
"\n".join(o[2] for o in outdated if o[2])
|
"\n".join(o[2] for o in outdated if o[2])
|
||||||
)
|
)
|
||||||
return msg
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _set(
|
def _set(
|
||||||
|
|||||||
@@ -279,8 +279,7 @@ API.register(get_system_file)
|
|||||||
|
|
||||||
param = sig.parameters.get(arg_name)
|
param = sig.parameters.get(arg_name)
|
||||||
if param:
|
if param:
|
||||||
param_class = param.annotation
|
return param.annotation
|
||||||
return param_class
|
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -105,9 +105,7 @@ def list_system_services_mdns() -> DNSInfo:
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
proc = run(cmd)
|
proc = run(cmd)
|
||||||
data = parse_avahi_output(proc.stdout)
|
return parse_avahi_output(proc.stdout)
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
def mdns_command(_args: argparse.Namespace) -> None:
|
def mdns_command(_args: argparse.Namespace) -> None:
|
||||||
|
|||||||
@@ -37,9 +37,7 @@ def inspect_dataclass_fields(t: type) -> dict[TypeVar, type]:
|
|||||||
|
|
||||||
type_params = origin.__parameters__
|
type_params = origin.__parameters__
|
||||||
# Create a map from type parameters to actual type arguments
|
# Create a map from type parameters to actual type arguments
|
||||||
type_map = dict(zip(type_params, type_args, strict=False))
|
return dict(zip(type_params, type_args, strict=False))
|
||||||
|
|
||||||
return type_map
|
|
||||||
|
|
||||||
|
|
||||||
def apply_annotations(schema: dict[str, Any], annotations: list[Any]) -> dict[str, Any]:
|
def apply_annotations(schema: dict[str, Any], annotations: list[Any]) -> dict[str, Any]:
|
||||||
|
|||||||
@@ -82,9 +82,7 @@ class PrefixFormatter(logging.Formatter):
|
|||||||
self.hostnames += [hostname]
|
self.hostnames += [hostname]
|
||||||
index = self.hostnames.index(hostname)
|
index = self.hostnames.index(hostname)
|
||||||
coloroffset = (index + self.hostname_color_offset) % len(colorcodes)
|
coloroffset = (index + self.hostname_color_offset) % len(colorcodes)
|
||||||
colorcode = colorcodes[coloroffset]
|
return colorcodes[coloroffset]
|
||||||
|
|
||||||
return colorcode
|
|
||||||
|
|
||||||
|
|
||||||
def get_callers(start: int = 2, end: int = 2) -> list[str]:
|
def get_callers(start: int = 2, end: int = 2) -> list[str]:
|
||||||
|
|||||||
@@ -530,10 +530,9 @@ class FlakeCacheEntry:
|
|||||||
msg = f"Expected dict for ALL selector caching, got {type(self.value)}"
|
msg = f"Expected dict for ALL selector caching, got {type(self.value)}"
|
||||||
raise ClanError(msg)
|
raise ClanError(msg)
|
||||||
if self.fetched_all:
|
if self.fetched_all:
|
||||||
result = all(
|
return all(
|
||||||
self.value[sel].is_cached(selectors[1:]) for sel in self.value
|
self.value[sel].is_cached(selectors[1:]) for sel in self.value
|
||||||
)
|
)
|
||||||
return result
|
|
||||||
return False
|
return False
|
||||||
if (
|
if (
|
||||||
selector.type == SelectorType.SET
|
selector.type == SelectorType.SET
|
||||||
@@ -724,13 +723,12 @@ class FlakeCacheEntry:
|
|||||||
exists = json_data.get("exists", True)
|
exists = json_data.get("exists", True)
|
||||||
fetched_all = json_data.get("fetched_all", False)
|
fetched_all = json_data.get("fetched_all", False)
|
||||||
|
|
||||||
entry = FlakeCacheEntry(
|
return FlakeCacheEntry(
|
||||||
value=value,
|
value=value,
|
||||||
is_list=is_list,
|
is_list=is_list,
|
||||||
exists=exists,
|
exists=exists,
|
||||||
fetched_all=fetched_all,
|
fetched_all=fetched_all,
|
||||||
)
|
)
|
||||||
return entry
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
if isinstance(self.value, dict):
|
if isinstance(self.value, dict):
|
||||||
@@ -1087,8 +1085,7 @@ class Flake:
|
|||||||
else:
|
else:
|
||||||
log.debug(f"$ clan select {shlex.quote(selector)}")
|
log.debug(f"$ clan select {shlex.quote(selector)}")
|
||||||
|
|
||||||
value = self._cache.select(selector)
|
return self._cache.select(selector)
|
||||||
return value
|
|
||||||
|
|
||||||
def select_machine(self, machine_name: str, selector: str) -> Any:
|
def select_machine(self, machine_name: str, selector: str) -> Any:
|
||||||
"""Select a nix attribute for a specific machine.
|
"""Select a nix attribute for a specific machine.
|
||||||
|
|||||||
@@ -47,9 +47,7 @@ def configured_log_manager(base_dir: Path) -> LogManager:
|
|||||||
clans_config = LogGroupConfig("clans", "Clans")
|
clans_config = LogGroupConfig("clans", "Clans")
|
||||||
machines_config = LogGroupConfig("machines", "Machines")
|
machines_config = LogGroupConfig("machines", "Machines")
|
||||||
clans_config = clans_config.add_child(machines_config)
|
clans_config = clans_config.add_child(machines_config)
|
||||||
log_manager = log_manager.add_root_group_config(clans_config)
|
return log_manager.add_root_group_config(clans_config)
|
||||||
|
|
||||||
return log_manager
|
|
||||||
|
|
||||||
|
|
||||||
class TestLogGroupConfig:
|
class TestLogGroupConfig:
|
||||||
|
|||||||
@@ -133,8 +133,7 @@ class Machine:
|
|||||||
remote = get_machine_host(self.name, self.flake, field="buildHost")
|
remote = get_machine_host(self.name, self.flake, field="buildHost")
|
||||||
|
|
||||||
if remote:
|
if remote:
|
||||||
data = remote.data
|
return remote.data
|
||||||
return data
|
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -65,12 +65,11 @@ class Network:
|
|||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def module(self) -> "NetworkTechnologyBase":
|
def module(self) -> "NetworkTechnologyBase":
|
||||||
res = import_with_source(
|
return import_with_source(
|
||||||
self.module_name,
|
self.module_name,
|
||||||
"NetworkTechnology",
|
"NetworkTechnology",
|
||||||
NetworkTechnologyBase, # type: ignore[type-abstract]
|
NetworkTechnologyBase, # type: ignore[type-abstract]
|
||||||
)
|
)
|
||||||
return res
|
|
||||||
|
|
||||||
def is_running(self) -> bool:
|
def is_running(self) -> bool:
|
||||||
return self.module.is_running()
|
return self.module.is_running()
|
||||||
|
|||||||
@@ -103,8 +103,7 @@ def nix_eval(flags: list[str]) -> list[str]:
|
|||||||
def nix_metadata(flake_url: str | Path) -> dict[str, Any]:
|
def nix_metadata(flake_url: str | Path) -> dict[str, Any]:
|
||||||
cmd = nix_command(["flake", "metadata", "--json", f"{flake_url}"])
|
cmd = nix_command(["flake", "metadata", "--json", f"{flake_url}"])
|
||||||
proc = run(cmd)
|
proc = run(cmd)
|
||||||
data = json.loads(proc.stdout)
|
return json.loads(proc.stdout)
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
# lazy loads list of allowed and static programs
|
# lazy loads list of allowed and static programs
|
||||||
|
|||||||
@@ -151,9 +151,7 @@ class InventoryStore:
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
filtered = cast("InventorySnapshot", raw_value)
|
filtered = cast("InventorySnapshot", raw_value)
|
||||||
sanitized = sanitize(filtered, self._allowed_path_transforms, [])
|
return sanitize(filtered, self._allowed_path_transforms, [])
|
||||||
|
|
||||||
return sanitized
|
|
||||||
|
|
||||||
def get_readonly_raw(self) -> Inventory:
|
def get_readonly_raw(self) -> Inventory:
|
||||||
attrs = "{" + ",".join(self._keys) + "}"
|
attrs = "{" + ",".join(self._keys) + "}"
|
||||||
|
|||||||
@@ -138,8 +138,7 @@ def list_difference(all_items: list, filter_items: list) -> list:
|
|||||||
|
|
||||||
def find_duplicates(string_list: list[str]) -> list[str]:
|
def find_duplicates(string_list: list[str]) -> list[str]:
|
||||||
count = Counter(string_list)
|
count = Counter(string_list)
|
||||||
duplicates = [item for item, freq in count.items() if freq > 1]
|
return [item for item, freq in count.items() if freq > 1]
|
||||||
return duplicates
|
|
||||||
|
|
||||||
|
|
||||||
def find_deleted_paths(
|
def find_deleted_paths(
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from tempfile import NamedTemporaryFile
|
|||||||
def create_sandbox_profile() -> str:
|
def create_sandbox_profile() -> str:
|
||||||
"""Create a sandbox profile that allows access to tmpdir and nix store, based on Nix's sandbox-defaults.sb."""
|
"""Create a sandbox profile that allows access to tmpdir and nix store, based on Nix's sandbox-defaults.sb."""
|
||||||
# Based on Nix's sandbox-defaults.sb implementation with TMPDIR parameter
|
# Based on Nix's sandbox-defaults.sb implementation with TMPDIR parameter
|
||||||
profile_content = """(version 1)
|
return """(version 1)
|
||||||
|
|
||||||
(define TMPDIR (param "_TMPDIR"))
|
(define TMPDIR (param "_TMPDIR"))
|
||||||
|
|
||||||
@@ -92,8 +92,6 @@ def create_sandbox_profile() -> str:
|
|||||||
(allow process-exec (literal "/usr/bin/env"))
|
(allow process-exec (literal "/usr/bin/env"))
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return profile_content
|
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def sandbox_exec_cmd(generator: str, tmpdir: Path) -> Iterator[list[str]]:
|
def sandbox_exec_cmd(generator: str, tmpdir: Path) -> Iterator[list[str]]:
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ def list_service_instances(flake: Flake) -> InventoryInstancesType:
|
|||||||
"""Returns all currently present service instances including their full configuration"""
|
"""Returns all currently present service instances including their full configuration"""
|
||||||
inventory_store = InventoryStore(flake)
|
inventory_store = InventoryStore(flake)
|
||||||
inventory = inventory_store.read()
|
inventory = inventory_store.read()
|
||||||
instances = inventory.get("instances", {})
|
return inventory.get("instances", {})
|
||||||
return instances
|
|
||||||
|
|
||||||
|
|
||||||
def collect_tags(machines: InventoryMachinesType) -> set[str]:
|
def collect_tags(machines: InventoryMachinesType) -> set[str]:
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ def create_secret_key_nixos_anywhere() -> SSHKeyPair:
|
|||||||
"""
|
"""
|
||||||
private_key_dir = user_nixos_anywhere_dir()
|
private_key_dir = user_nixos_anywhere_dir()
|
||||||
|
|
||||||
key_pair = generate_ssh_key(private_key_dir)
|
return generate_ssh_key(private_key_dir)
|
||||||
|
|
||||||
return key_pair
|
|
||||||
|
|
||||||
|
|
||||||
def generate_ssh_key(root_dir: Path) -> SSHKeyPair:
|
def generate_ssh_key(root_dir: Path) -> SSHKeyPair:
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ def test_list_inventory_tags(clan_flake: Callable[..., Flake]) -> None:
|
|||||||
inventory_store.write(inventory, message="Test add tags via API")
|
inventory_store.write(inventory, message="Test add tags via API")
|
||||||
|
|
||||||
# Check that the tags were updated
|
# Check that the tags were updated
|
||||||
persisted = inventory_store._get_persisted() # noqa: SLF001
|
persisted = inventory_store._get_persisted()
|
||||||
assert get_value_by_path(persisted, "machines.jon.tags", []) == new_tags
|
assert get_value_by_path(persisted, "machines.jon.tags", []) == new_tags
|
||||||
|
|
||||||
tags = list_tags(flake)
|
tags = list_tags(flake)
|
||||||
|
|||||||
@@ -135,16 +135,14 @@ def indent_next(text: str, indent_size: int = 4) -> str:
|
|||||||
"""
|
"""
|
||||||
indent = " " * indent_size
|
indent = " " * indent_size
|
||||||
lines = text.split("\n")
|
lines = text.split("\n")
|
||||||
indented_text = lines[0] + ("\n" + indent).join(lines[1:])
|
return lines[0] + ("\n" + indent).join(lines[1:])
|
||||||
return indented_text
|
|
||||||
|
|
||||||
|
|
||||||
def indent_all(text: str, indent_size: int = 4) -> str:
|
def indent_all(text: str, indent_size: int = 4) -> str:
|
||||||
"""Indent all lines in a string."""
|
"""Indent all lines in a string."""
|
||||||
indent = " " * indent_size
|
indent = " " * indent_size
|
||||||
lines = text.split("\n")
|
lines = text.split("\n")
|
||||||
indented_text = indent + ("\n" + indent).join(lines)
|
return indent + ("\n" + indent).join(lines)
|
||||||
return indented_text
|
|
||||||
|
|
||||||
|
|
||||||
def get_subcommands(
|
def get_subcommands(
|
||||||
|
|||||||
@@ -138,6 +138,4 @@ def spawn(
|
|||||||
proc.start()
|
proc.start()
|
||||||
|
|
||||||
# Return the process
|
# Return the process
|
||||||
mp_proc = MPProcess(name=proc_name, proc=proc, out_file=out_file)
|
return MPProcess(name=proc_name, proc=proc, out_file=out_file)
|
||||||
|
|
||||||
return mp_proc
|
|
||||||
|
|||||||
@@ -181,8 +181,7 @@ class ClanStore:
|
|||||||
|
|
||||||
if vm_store is None:
|
if vm_store is None:
|
||||||
return None
|
return None
|
||||||
vm = vm_store.get(str(machine.name), None)
|
return vm_store.get(str(machine.name), None)
|
||||||
return vm
|
|
||||||
|
|
||||||
def get_running_vms(self) -> list[VMObject]:
|
def get_running_vms(self) -> list[VMObject]:
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -48,8 +48,7 @@ def list_devshells() -> list[str]:
|
|||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
check=True,
|
check=True,
|
||||||
)
|
)
|
||||||
names = json.loads(flake_show.stdout.decode())
|
return json.loads(flake_show.stdout.decode())
|
||||||
return names
|
|
||||||
|
|
||||||
|
|
||||||
def print_devshells() -> None:
|
def print_devshells() -> None:
|
||||||
|
|||||||
@@ -58,9 +58,7 @@ def compute_member_id(ipv6_addr: str) -> str:
|
|||||||
node_id_bytes = addr_bytes[10:16]
|
node_id_bytes = addr_bytes[10:16]
|
||||||
node_id = int.from_bytes(node_id_bytes, byteorder="big")
|
node_id = int.from_bytes(node_id_bytes, byteorder="big")
|
||||||
|
|
||||||
member_id = format(node_id, "x").zfill(10)[-10:]
|
return format(node_id, "x").zfill(10)[-10:]
|
||||||
|
|
||||||
return member_id
|
|
||||||
|
|
||||||
|
|
||||||
# this is managed by the nixos module
|
# this is managed by the nixos module
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ lint.ignore = [
|
|||||||
"PLR2004",
|
"PLR2004",
|
||||||
"PT001",
|
"PT001",
|
||||||
"PT023",
|
"PT023",
|
||||||
"RET504",
|
|
||||||
"RUF100",
|
"RUF100",
|
||||||
"S603",
|
"S603",
|
||||||
"S607",
|
"S607",
|
||||||
|
|||||||
Reference in New Issue
Block a user