disko2: Create package

This requires a lot of restructuring. The .nix files have to be bundled
together with the python files, so they need to follow python's module
system structure.

I ran `nix-fast-build --no-link -j 2 --eval-workers 3 --flake .#checks`
and it succeeded, so I'm reasonably confident I changed everything as
required.
This commit is contained in:
Felix Uhl committed 2024-10-30 23:54:41 +01:00
1 parent 5da578139e
commit 389235b63f
88 files changed
+374 -282

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
import subprocess
from .logging import debug
from .result import DiskoError, DiskoResult, DiskoSuccess
def run(args: list[str]) -> DiskoResult[str]:
command = " ".join(args)
debug(f"Running: {command}")
result = subprocess.run(args, capture_output=True, text=True)
debug(
f"""
Ran: {command}
Exit code: {result.returncode}
Stdout: {result.stdout}
Stderr: {result.stderr}
"""
)
if result.returncode == 0:
return DiskoSuccess(result.stdout, "run command")
return DiskoError.single_message(
"ERR_COMMAND_FAILED",
{
"command": command,
"stderr": result.stderr,
"exit_code": result.returncode,
},
"run command",
)