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

Function init_podman_command

dangerzone/container_utils.py:191–231  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

189
190@functools.cache
191def init_podman_command() -> PodmanCommand:
192 podman_path: Path | None
193 settings = Settings()
194
195 if settings.custom_runtime_specified():
196 podman_path = Path(settings.get("container_runtime"))
197 if not podman_path.exists():
198 raise errors.UnsupportedContainerRuntime(podman_path)
199 else:
200 podman_path = get_podman_path()
201
202 options = env = None
203 if platform.system() != "Linux" and not settings.custom_runtime_specified():
204 env = os.environ.copy()
205 env["CONTAINERS_CONF"] = str(create_containers_conf())
206 options = PodmanCommand.GlobalOptions(
207 connection=PODMAN_MACHINE_NAME,
208 storage_opt="overlay.mount_program=/usr/bin/fuse-overlayfs",
209 )
210 if settings.debug:
211 options.log_level = "debug"
212 elif linux_system_is("Tails"):
213 env = os.environ.copy()
214 env["HTTPS_PROXY"] = get_tails_socks_proxy()
215 try:
216 return PodmanCommand(path=podman_path, env=env, options=options)
217 except PodmanNotInstalled:
218 if getattr(sys, "dangerzone_dev", False):
219 raise errors.ContainerException(
220 "It seems that Podman is not present in your development environment."
221 " You can run `mazette install` to download and install it."
222 f" Expected path: {podman_path}"
223 )
224 else:
225 raise errors.ContainerException(
226 "Dangerzone could not find the Podman binary locally, which"
227 " is necessary to start containers. This binary should be included as"
228 " part of the installation, so the fact that it's missing indicates"
229 " that your installation may be broken. You can try reinstalling"
230 " Dangerzone, but if the problem persists, please contact us."
231 )
232
233
234def list_image_digests() -> list[str]:

Callers 12

ensure_container_imageFunction · 0.90
runtime_pathFunction · 0.90
get_runtime_versionFunction · 0.85
list_image_digestsFunction · 0.85
list_containersFunction · 0.85
kill_containerFunction · 0.85
delete_image_digestsFunction · 0.85
load_image_tarballFunction · 0.85
tag_image_by_digestFunction · 0.85
get_image_id_by_digestFunction · 0.85
container_pullFunction · 0.85
get_local_image_digestFunction · 0.85

Calls 8

getMethod · 0.95
SettingsClass · 0.85
get_podman_pathFunction · 0.85
create_containers_confFunction · 0.85
linux_system_isFunction · 0.85
get_tails_socks_proxyFunction · 0.85
PodmanCommandClass · 0.85

Tested by 2

ensure_container_imageFunction · 0.72
runtime_pathFunction · 0.72