feat: add presets

This commit is contained in:
2023-03-16 15:07:11 +03:00
parent 23ca8c0cac
commit 8b718fda79
15 changed files with 357 additions and 142 deletions
+7 -9
View File
@@ -1,6 +1,6 @@
__all__ = (
"CommandError",
"Command",
"CommandExecutor",
)
@@ -8,7 +8,7 @@ import logging
import subprocess
from pathlib import Path
logger = logging.getLogger(">")
logger = logging.getLogger("command")
class CommandError(RuntimeError):
@@ -17,18 +17,16 @@ class CommandError(RuntimeError):
return self.args[0].decode("utf-8").strip()
class Command:
class CommandExecutor:
_logger = logger
def __init__(self, executor: str, *args: str) -> None:
self._executor = executor
self._args = args
def __init__(self, command: str) -> None:
self._command = command
def run(self, basepath: Path):
args = [self._executor, *self._args]
self._logger.debug(" ".join(args))
self._logger.debug(self._command)
result = subprocess.run(
args,
self._command.split(" "),
cwd=basepath,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,