MCPcopy
hub / github.com/freedomofpress/dangerzone / PodmanCommand

Class PodmanCommand

dangerzone/podman/command/command.py:17–225  ·  view source on GitHub ↗

Main class for executing Podman commands. Attributes: runner (cli_runner.Runner): The runner instance to execute commands. machine (machine_manager.MachineManager): Manager for machine operations.

Source from the content-addressed store, hash-verified

15
16
17class PodmanCommand:
18 """Main class for executing Podman commands.
19
20 Attributes:
21 runner (cli_runner.Runner): The runner instance to execute commands.
22 machine (machine_manager.MachineManager): Manager for machine operations.
23 """
24
25 GlobalOptions = cli_runner.GlobalOptions
26
27 def __init__(
28 self,
29 path: Path | None = None,
30 privileged: bool = False,
31 options: cli_runner.GlobalOptions | None = None,
32 env: dict | None = None,
33 ):
34 """Initialize the PodmanCommand.
35
36 Args:
37 path (Path, optional): Path to the Podman executable. Defaults to None.
38 privileged (bool, optional): Whether to run commands with elevated privileges. Defaults to False.
39 options (cli_runner.GlobalOptions, optional): Global options for Podman commands. Defaults to a new instance of GlobalOptions.
40 env (dict, optional): Environment variables for the subprocess. Defaults to None.
41 """
42 if options is None:
43 options = cli_runner.GlobalOptions()
44 self.runner = cli_runner.Runner(
45 path=path,
46 privileged=privileged,
47 options=options,
48 env=env,
49 )
50 self.machine = machine_manager.MachineManager(self.runner)
51 self.proc_service: subprocess.Popen | None = None
52
53 def run(
54 self,
55 cmd: list[str],
56 *,
57 check: bool = True,
58 capture_output=True,
59 wait=True,
60 **skwargs,
61 ) -> str | subprocess.Popen:
62 """Run the specified Podman command.
63
64 Args:
65 cmd (list[str]): The command to run, as a list of strings.
66 check (bool, optional): Whether to check for errors. Defaults to True.
67 capture_output (bool, optional): Whether to capture output. Defaults to True.
68 wait (bool, optional): Whether to wait for the command to complete. Defaults to True.
69 **skwargs: Additional keyword arguments for subprocess.
70
71 Returns:
72 Optional[str]: The output of the command if captured, otherwise the
73 subprocess.Popen instance.
74

Callers 1

init_podman_commandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected