|
|
@@ -88,3 +88,25 @@ class Podman:
|
|
|
print(f"Executing `{" ".join(args)}`")
|
|
|
out = subprocess.check_output(args, **kwargs)
|
|
|
print(out.decode())
|
|
|
+
|
|
|
+ @classmethod
|
|
|
+ def ps(cls):
|
|
|
+ out = subprocess.run(["podman", "ps"], capture_output=True, check=True)
|
|
|
+
|
|
|
+ @classmethod
|
|
|
+ def _call(cls, args: list, **kwargs):
|
|
|
+ args = ["podman"] + args
|
|
|
+ print(f"Executing `{" ".join(args)}`")
|
|
|
+ try:
|
|
|
+ out = subprocess.check_output(args, **kwargs)
|
|
|
+ print(out.decode())
|
|
|
+ except subprocess.CalledProcessError as e:
|
|
|
+ print(e)
|
|
|
+ try:
|
|
|
+ cls.ps()
|
|
|
+ except subprocess.CalledProcessError as e2:
|
|
|
+ if "Cannot connect to Podman" in e2.stderr.decode():
|
|
|
+ print("podman not running, starting it")
|
|
|
+ subprocess.check_output(["podman", "machine", "start"])
|
|
|
+ out = subprocess.check_output(args, **kwargs)
|
|
|
+ print(out.decode())
|