API: Added Path validators. api/flake/create inits git repo. Fixed vscode interpreter problem

This commit is contained in:
Qubasa
2023-10-12 22:46:32 +02:00
parent cc96fcf916
commit fa5f39f226
18 changed files with 186 additions and 56 deletions

View File

@@ -2,14 +2,19 @@ import asyncio
import logging
import shlex
from pathlib import Path
from typing import Optional, Tuple
from typing import NamedTuple, Optional
from .errors import ClanError
log = logging.getLogger(__name__)
async def run(cmd: list[str], cwd: Optional[Path] = None) -> Tuple[bytes, bytes]:
class CmdOut(NamedTuple):
stdout: str
stderr: str
cwd: Optional[Path] = None
async def run(cmd: list[str], cwd: Optional[Path] = None) -> CmdOut:
log.debug(f"$: {shlex.join(cmd)}")
cwd_res = None
if cwd is not None:
@@ -36,4 +41,5 @@ command output:
{stderr.decode("utf-8")}
"""
)
return stdout, stderr
return CmdOut(stdout.decode("utf-8"), stderr.decode("utf-8"), cwd=cwd)