|
|
@@ -39,7 +39,7 @@ class Podman:
|
|
|
|
|
|
args += [image]
|
|
|
|
|
|
- cls._call(args)
|
|
|
+ cls._check_output(args)
|
|
|
|
|
|
@classmethod
|
|
|
def rm(cls, name, *, force=True):
|
|
|
@@ -47,12 +47,18 @@ class Podman:
|
|
|
if force:
|
|
|
args += ["-f"]
|
|
|
args += [name]
|
|
|
- cls._call(args)
|
|
|
+ cls._check_output(args)
|
|
|
|
|
|
@classmethod
|
|
|
- def exec(cls, name, *cmd):
|
|
|
- args = ["exec", "-ti", name] + list(cmd)
|
|
|
- cls._call(args)
|
|
|
+ def exec(cls, name, /, *cmd, interactive):
|
|
|
+ args = ["exec"]
|
|
|
+ common_suffix = [name] + list(cmd)
|
|
|
+ if interactive:
|
|
|
+ args += ["-ti"] + common_suffix
|
|
|
+ cls._run(args)
|
|
|
+ else:
|
|
|
+ args += common_suffix
|
|
|
+ cls._check_output(args)
|
|
|
|
|
|
@classmethod
|
|
|
def secret_create(
|
|
|
@@ -80,14 +86,7 @@ class Podman:
|
|
|
elif host_path is not None:
|
|
|
args += [host_path]
|
|
|
|
|
|
- cls._call(args, **kwargs)
|
|
|
-
|
|
|
- @classmethod
|
|
|
- def _call(cls, args: list, **kwargs):
|
|
|
- args = ["podman"] + args
|
|
|
- print(f"Executing `{" ".join(args)}`")
|
|
|
- out = subprocess.check_output(args, **kwargs)
|
|
|
- print(out.decode())
|
|
|
+ cls._check_output(args, **kwargs)
|
|
|
|
|
|
@classmethod
|
|
|
def machine_is_running(cls) -> bool:
|
|
|
@@ -101,10 +100,17 @@ class Podman:
|
|
|
|
|
|
@classmethod
|
|
|
def machine_start(cls):
|
|
|
- cls._call(["machine", "start"])
|
|
|
+ cls._check_output(["machine", "start"])
|
|
|
+
|
|
|
+ @classmethod
|
|
|
+ def _run(cls, args: list, **kwargs):
|
|
|
+ args = ["podman"] + args
|
|
|
+ print(f"Executing `{" ".join(args)}`")
|
|
|
+
|
|
|
+ return subprocess.run(args, **kwargs)
|
|
|
|
|
|
@classmethod
|
|
|
- def _call(cls, args: list, **kwargs):
|
|
|
+ def _check_output(cls, args: list, **kwargs):
|
|
|
args = ["podman"] + args
|
|
|
print(f"Executing `{" ".join(args)}`")
|
|
|
|