Merge pull request 'move templates, custom_logger, async_run and jsonrpc to clan_lib' (#3720) from clan_lib_misc into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3720
This commit is contained in:
@@ -7,8 +7,8 @@ import os
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from clan_cli.custom_logger import setup_logging
|
|
||||||
from clan_lib.api import API, ErrorDataClass, SuccessDataClass
|
from clan_lib.api import API, ErrorDataClass, SuccessDataClass
|
||||||
|
from clan_lib.custom_logger import setup_logging
|
||||||
|
|
||||||
from clan_app.api.file_gtk import open_file
|
from clan_app.api.file_gtk import open_file
|
||||||
from clan_app.deps.webview.webview import Size, SizeHint, Webview
|
from clan_app.deps.webview.webview import Size, SizeHint, Webview
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ from dataclasses import dataclass
|
|||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from clan_cli.async_run import set_should_cancel
|
|
||||||
from clan_lib.api import (
|
from clan_lib.api import (
|
||||||
ApiError,
|
ApiError,
|
||||||
ErrorDataClass,
|
ErrorDataClass,
|
||||||
@@ -16,6 +15,7 @@ from clan_lib.api import (
|
|||||||
dataclass_to_dict,
|
dataclass_to_dict,
|
||||||
from_dict,
|
from_dict,
|
||||||
)
|
)
|
||||||
|
from clan_lib.async_run import set_should_cancel
|
||||||
|
|
||||||
from ._webview_ffi import _encode_c_string, _webview_lib
|
from ._webview_ffi import _encode_c_string, _webview_lib
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import subprocess
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from clan_cli.custom_logger import setup_logging
|
from clan_lib.custom_logger import setup_logging
|
||||||
from clan_lib.nix import nix_shell
|
from clan_lib.nix import nix_shell
|
||||||
|
|
||||||
pytest_plugins = [
|
pytest_plugins = [
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import os
|
|||||||
import shlex
|
import shlex
|
||||||
|
|
||||||
from clan_app import main
|
from clan_app import main
|
||||||
from clan_cli.custom_logger import get_callers
|
from clan_lib.custom_logger import get_callers
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ from .clan import show, update
|
|||||||
# API endpoints that are not used in the cli.
|
# API endpoints that are not used in the cli.
|
||||||
__all__ = ["directory", "disk", "mdns_discovery", "modules", "update"]
|
__all__ = ["directory", "disk", "mdns_discovery", "modules", "update"]
|
||||||
|
|
||||||
|
from clan_lib.custom_logger import setup_logging
|
||||||
from clan_lib.dirs import get_clan_flake_toplevel_or_env
|
from clan_lib.dirs import get_clan_flake_toplevel_or_env
|
||||||
from clan_lib.errors import ClanError
|
from clan_lib.errors import ClanError
|
||||||
from clan_lib.flake import Flake
|
from clan_lib.flake import Flake
|
||||||
@@ -26,7 +27,6 @@ from . import (
|
|||||||
state,
|
state,
|
||||||
vms,
|
vms,
|
||||||
)
|
)
|
||||||
from .custom_logger import setup_logging
|
|
||||||
from .facts import cli as facts
|
from .facts import cli as facts
|
||||||
from .flash import cli as flash_cli
|
from .flash import cli as flash_cli
|
||||||
from .hyperlink import help_hyperlink
|
from .hyperlink import help_hyperlink
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ from clan_lib.flake import Flake
|
|||||||
from clan_lib.nix import nix_command, nix_metadata, nix_shell
|
from clan_lib.nix import nix_command, nix_metadata, nix_shell
|
||||||
from clan_lib.nix_models.inventory import Inventory
|
from clan_lib.nix_models.inventory import Inventory
|
||||||
from clan_lib.persist.inventory_store import InventoryStore
|
from clan_lib.persist.inventory_store import InventoryStore
|
||||||
|
from clan_lib.templates import (
|
||||||
from clan_cli.templates import (
|
|
||||||
InputPrio,
|
InputPrio,
|
||||||
TemplateName,
|
TemplateName,
|
||||||
copy_from_nixstore,
|
copy_from_nixstore,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from clan_cli.templates import list_templates
|
from clan_lib.templates import list_templates
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -17,16 +17,16 @@ from clan_lib.nix_models.inventory import (
|
|||||||
)
|
)
|
||||||
from clan_lib.persist.inventory_store import InventoryStore
|
from clan_lib.persist.inventory_store import InventoryStore
|
||||||
from clan_lib.persist.util import apply_patch
|
from clan_lib.persist.util import apply_patch
|
||||||
|
from clan_lib.templates import (
|
||||||
from clan_cli.completions import add_dynamic_completer, complete_tags
|
|
||||||
from clan_cli.machines.list import list_machines
|
|
||||||
from clan_cli.templates import (
|
|
||||||
InputPrio,
|
InputPrio,
|
||||||
TemplateName,
|
TemplateName,
|
||||||
copy_from_nixstore,
|
copy_from_nixstore,
|
||||||
get_template,
|
get_template,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from clan_cli.completions import add_dynamic_completer, complete_tags
|
||||||
|
from clan_cli.machines.list import list_machines
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ import sys
|
|||||||
from contextlib import ExitStack
|
from contextlib import ExitStack
|
||||||
|
|
||||||
from clan_lib.api import API
|
from clan_lib.api import API
|
||||||
|
from clan_lib.async_run import AsyncContext, AsyncOpts, AsyncRuntime, is_async_cancelled
|
||||||
from clan_lib.cmd import Log, MsgColor, RunOpts, run
|
from clan_lib.cmd import Log, MsgColor, RunOpts, run
|
||||||
from clan_lib.colors import AnsiColor
|
from clan_lib.colors import AnsiColor
|
||||||
from clan_lib.errors import ClanError
|
from clan_lib.errors import ClanError
|
||||||
from clan_lib.nix import nix_command, nix_config, nix_metadata
|
from clan_lib.nix import nix_command, nix_config, nix_metadata
|
||||||
|
|
||||||
from clan_cli.async_run import AsyncContext, AsyncOpts, AsyncRuntime, is_async_cancelled
|
|
||||||
from clan_cli.completions import (
|
from clan_cli.completions import (
|
||||||
add_dynamic_completer,
|
add_dynamic_completer,
|
||||||
complete_machines,
|
complete_machines,
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ from dataclasses import dataclass
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from clan_lib.async_run import AsyncRuntime
|
||||||
from clan_lib.cmd import run
|
from clan_lib.cmd import run
|
||||||
from clan_lib.errors import ClanError
|
from clan_lib.errors import ClanError
|
||||||
from clan_lib.nix import nix_shell
|
from clan_lib.nix import nix_shell
|
||||||
|
|
||||||
from clan_cli.async_run import AsyncRuntime
|
|
||||||
from clan_cli.completions import (
|
from clan_cli.completions import (
|
||||||
add_dynamic_completer,
|
add_dynamic_completer,
|
||||||
complete_machines,
|
complete_machines,
|
||||||
|
|||||||
@@ -7,12 +7,11 @@ import struct
|
|||||||
import time
|
import time
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
from clan_lib.async_run import AsyncRuntime
|
||||||
from clan_lib.cmd import Log, RunOpts, run
|
from clan_lib.cmd import Log, RunOpts, run
|
||||||
from clan_lib.errors import TorConnectionError, TorSocksError
|
from clan_lib.errors import TorConnectionError, TorSocksError
|
||||||
from clan_lib.nix import nix_shell
|
from clan_lib.nix import nix_shell
|
||||||
|
|
||||||
from clan_cli.async_run import AsyncRuntime
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import logging
|
|||||||
import shlex
|
import shlex
|
||||||
|
|
||||||
from clan_cli import create_parser
|
from clan_cli import create_parser
|
||||||
from clan_cli.custom_logger import print_trace
|
from clan_lib.custom_logger import print_trace
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from clan_cli.async_run import AsyncRuntime
|
from clan_lib.async_run import AsyncRuntime
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ from pathlib import Path
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from clan_cli.templates import (
|
from clan_cli.tests.fixtures_flakes import FlakeForTest
|
||||||
|
from clan_lib.cmd import run
|
||||||
|
from clan_lib.flake import Flake
|
||||||
|
from clan_lib.git import commit_file
|
||||||
|
from clan_lib.locked_open import locked_open
|
||||||
|
from clan_lib.nix import nix_command
|
||||||
|
from clan_lib.templates import (
|
||||||
ClanExports,
|
ClanExports,
|
||||||
InputName,
|
InputName,
|
||||||
TemplateName,
|
TemplateName,
|
||||||
@@ -14,12 +20,6 @@ from clan_cli.templates import (
|
|||||||
get_template,
|
get_template,
|
||||||
list_templates,
|
list_templates,
|
||||||
)
|
)
|
||||||
from clan_cli.tests.fixtures_flakes import FlakeForTest
|
|
||||||
from clan_lib.cmd import run
|
|
||||||
from clan_lib.flake import Flake
|
|
||||||
from clan_lib.git import commit_file
|
|
||||||
from clan_lib.locked_open import locked_open
|
|
||||||
from clan_lib.nix import nix_command
|
|
||||||
|
|
||||||
|
|
||||||
# Function to write clan attributes to a file
|
# Function to write clan attributes to a file
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from clan_cli.async_run import AsyncRuntime
|
|
||||||
from clan_cli.ssh.host import Host
|
from clan_cli.ssh.host import Host
|
||||||
|
from clan_lib.async_run import AsyncRuntime
|
||||||
from clan_lib.cmd import ClanCmdTimeoutError, Log, RunOpts
|
from clan_lib.cmd import ClanCmdTimeoutError, Log, RunOpts
|
||||||
|
|
||||||
host = Host("some_host")
|
host = Host("some_host")
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ from collections.abc import Generator
|
|||||||
from typing import Any, NamedTuple
|
from typing import Any, NamedTuple
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from clan_cli.async_run import AsyncRuntime
|
|
||||||
from clan_cli.ssh.host import Host
|
from clan_cli.ssh.host import Host
|
||||||
from clan_cli.ssh.host_key import HostKeyCheck
|
from clan_cli.ssh.host_key import HostKeyCheck
|
||||||
from clan_cli.ssh.parse import parse_deployment_address
|
from clan_cli.ssh.parse import parse_deployment_address
|
||||||
|
from clan_lib.async_run import AsyncRuntime
|
||||||
from clan_lib.cmd import ClanCmdTimeoutError, Log, RunOpts
|
from clan_lib.cmd import ClanCmdTimeoutError, Log, RunOpts
|
||||||
from clan_lib.errors import ClanError, CmdOut
|
from clan_lib.errors import ClanError, CmdOut
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,9 @@ from enum import Enum
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import IO, Any
|
from typing import IO, Any
|
||||||
|
|
||||||
from clan_cli.async_run import get_async_ctx, is_async_cancelled
|
from clan_lib.async_run import get_async_ctx, is_async_cancelled
|
||||||
from clan_cli.custom_logger import print_trace
|
|
||||||
|
|
||||||
from clan_lib.colors import Color
|
from clan_lib.colors import Color
|
||||||
|
from clan_lib.custom_logger import print_trace
|
||||||
from clan_lib.errors import ClanCmdError, ClanError, CmdOut, indent_command
|
from clan_lib.errors import ClanCmdError, ClanError, CmdOut, indent_command
|
||||||
|
|
||||||
cmdlog = logging.getLogger(__name__)
|
cmdlog = logging.getLogger(__name__)
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ def clan_templates(template_type: TemplateType | None = None) -> Path:
|
|||||||
if template_path.exists():
|
if template_path.exists():
|
||||||
return template_path
|
return template_path
|
||||||
|
|
||||||
template_path = module_root() / "templates"
|
template_path = module_root() / "clan_core_templates"
|
||||||
|
|
||||||
if template_type is not None:
|
if template_type is not None:
|
||||||
template_path /= template_type.value
|
template_path /= template_type.value
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import contextlib
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -373,7 +374,8 @@ def test_cache_gc(monkeypatch: pytest.MonkeyPatch) -> None:
|
|||||||
monkeypatch.setenv("NIX_STORE_DIR", str(tempdir / "store"))
|
monkeypatch.setenv("NIX_STORE_DIR", str(tempdir / "store"))
|
||||||
monkeypatch.setenv("NIX_CACHE_HOME", str(tempdir / "cache"))
|
monkeypatch.setenv("NIX_CACHE_HOME", str(tempdir / "cache"))
|
||||||
monkeypatch.setenv("HOME", str(tempdir / "home"))
|
monkeypatch.setenv("HOME", str(tempdir / "home"))
|
||||||
monkeypatch.delenv("CLAN_TEST_STORE")
|
with contextlib.suppress(KeyError):
|
||||||
|
monkeypatch.delenv("CLAN_TEST_STORE")
|
||||||
monkeypatch.setenv("NIX_BUILD_TOP", str(tempdir / "build"))
|
monkeypatch.setenv("NIX_BUILD_TOP", str(tempdir / "build"))
|
||||||
|
|
||||||
test_file = tempdir / "flake" / "testfile"
|
test_file = tempdir / "flake" / "testfile"
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ from contextlib import contextmanager
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from clan_cli.jsonrpc import ClanJSONEncoder
|
|
||||||
|
|
||||||
from clan_lib.dirs import user_history_file
|
from clan_lib.dirs import user_history_file
|
||||||
|
from clan_lib.jsonrpc import ClanJSONEncoder
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from clan_cli.custom_logger import setup_logging
|
from clan_lib.custom_logger import setup_logging
|
||||||
|
|
||||||
# Every fixture registered here will be available in clan_cli and clan_lib
|
# Every fixture registered here will be available in clan_cli and clan_lib
|
||||||
pytest_plugins = [
|
pytest_plugins = [
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ let
|
|||||||
--replace-fail '@select_hash@' "$(jq -r '.nodes."nix-select".locked.narHash' ${../../flake.lock})"
|
--replace-fail '@select_hash@' "$(jq -r '.nodes."nix-select".locked.narHash' ${../../flake.lock})"
|
||||||
ln -sf ${nixpkgs'} $out/clan_lib/nixpkgs
|
ln -sf ${nixpkgs'} $out/clan_lib/nixpkgs
|
||||||
ln -sf ${nix-select} $out/clan_lib/select
|
ln -sf ${nix-select} $out/clan_lib/select
|
||||||
cp -r ${../../templates} $out/clan_lib/templates
|
cp -r ${../../templates} $out/clan_lib/clan_core_templates
|
||||||
'';
|
'';
|
||||||
|
|
||||||
sourceWithoutTests = cliSource (
|
sourceWithoutTests = cliSource (
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ exclude = ["clan_lib.nixpkgs*", "result"]
|
|||||||
[tool.setuptools.package-data]
|
[tool.setuptools.package-data]
|
||||||
clan_cli = [
|
clan_cli = [
|
||||||
"py.typed",
|
"py.typed",
|
||||||
"templates/**/*",
|
|
||||||
"vms/mimetypes/**/*",
|
"vms/mimetypes/**/*",
|
||||||
"webui/assets/**/*",
|
"webui/assets/**/*",
|
||||||
"flash/*.sh",
|
"flash/*.sh",
|
||||||
]
|
]
|
||||||
clan_lib = [
|
clan_lib = [
|
||||||
|
"clan_core_templates/**/*",
|
||||||
"**/allowed-packages.json",
|
"**/allowed-packages.json",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from clan_vm_manager.singletons.toast import InfoToast, ToastOverlay
|
|||||||
gi.require_version("Gtk", "4.0")
|
gi.require_version("Gtk", "4.0")
|
||||||
gi.require_version("Adw", "1")
|
gi.require_version("Adw", "1")
|
||||||
|
|
||||||
from clan_cli.custom_logger import setup_logging
|
from clan_lib.custom_logger import setup_logging
|
||||||
from gi.repository import Adw, Gdk, Gio, Gtk
|
from gi.repository import Adw, Gdk, Gio, Gtk
|
||||||
|
|
||||||
from clan_vm_manager.components.interfaces import ClanConfig
|
from clan_vm_manager.components.interfaces import ClanConfig
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import sys
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from clan_cli.custom_logger import setup_logging
|
from clan_lib.custom_logger import setup_logging
|
||||||
from clan_lib.nix import nix_shell
|
from clan_lib.nix import nix_shell
|
||||||
|
|
||||||
sys.path.append(str(Path(__file__).parent / "helpers"))
|
sys.path.append(str(Path(__file__).parent / "helpers"))
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
|
|
||||||
from clan_cli.custom_logger import get_callers
|
from clan_lib.custom_logger import get_callers
|
||||||
from clan_vm_manager import main
|
from clan_vm_manager import main
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|||||||
Reference in New Issue
Block a user