From d36f52614d15d763f9be95abdb2da5488ad2ceb5 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Mon, 13 Mar 2023 18:23:04 -0700 Subject: [stable-2.14] ansible-test - Improve code formatting (#79983) (#80206) * ansible-test - Add blank lines after docstrings * ansible-test - Preserve formatting of arg pairs * ansible-test - Remove unused string * ansible-test - Remove pointless dict() usage * ansible-test - Clean up initial func arg indenting * ansible-test - Clean up constructor arg indenting * ansible-test - Clean up func arg wrapping * ansible-test - Clean up comma and paren placement (cherry picked from commit 715ab99462b1799f4a0c1caeddf161e930adf13f) --- test/lib/ansible_test/_internal/docker_util.py | 35 ++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'test/lib/ansible_test/_internal/docker_util.py') diff --git a/test/lib/ansible_test/_internal/docker_util.py b/test/lib/ansible_test/_internal/docker_util.py index 6c38ddbd24..06f383b588 100644 --- a/test/lib/ansible_test/_internal/docker_util.py +++ b/test/lib/ansible_test/_internal/docker_util.py @@ -243,6 +243,7 @@ def get_docker_info(args: CommonConfig) -> DockerInfo: class SystemdControlGroupV1Status(enum.Enum): """The state of the cgroup v1 systemd hierarchy on the container host.""" + SUBSYSTEM_MISSING = 'The systemd cgroup subsystem was not found.' FILESYSTEM_NOT_MOUNTED = 'The "/sys/fs/cgroup/systemd" filesystem is not mounted.' MOUNT_TYPE_NOT_CORRECT = 'The "/sys/fs/cgroup/systemd" mount type is not correct.' @@ -252,6 +253,7 @@ class SystemdControlGroupV1Status(enum.Enum): @dataclasses.dataclass(frozen=True) class ContainerHostProperties: """Container host properties detected at run time.""" + audit_code: str max_open_files: int loginuid: t.Optional[int] @@ -411,7 +413,7 @@ def run_utility_container( options = options + [ '--name', name, '--rm', - ] + ] # fmt: skip if data: options.append('-i') @@ -423,6 +425,7 @@ def run_utility_container( class DockerCommand: """Details about the available docker command.""" + def __init__(self, command: str, executable: str, version: str) -> None: self.command = command self.executable = executable @@ -720,6 +723,7 @@ class DockerError(Exception): class ContainerNotFoundError(DockerError): """The container identified by `identifier` was not found.""" + def __init__(self, identifier: str) -> None: super().__init__('The container "%s" was not found.' % identifier) @@ -728,6 +732,7 @@ class ContainerNotFoundError(DockerError): class DockerInspect: """The results of `docker inspect` for a single container.""" + def __init__(self, args: CommonConfig, inspection: dict[str, t.Any]) -> None: self.args = args self.inspection = inspection @@ -847,6 +852,7 @@ def docker_network_disconnect(args: CommonConfig, container_id: str, network: st class DockerImageInspect: """The results of `docker image inspect` for a single image.""" + def __init__(self, args: CommonConfig, inspection: dict[str, t.Any]) -> None: self.args = args self.inspection = inspection @@ -909,6 +915,7 @@ def docker_image_inspect(args: CommonConfig, image: str, always: bool = False) - class DockerNetworkInspect: """The results of `docker network inspect` for a single network.""" + def __init__(self, args: CommonConfig, inspection: dict[str, t.Any]) -> None: self.args = args self.inspection = inspection @@ -961,8 +968,16 @@ def docker_exec( if data or stdin or stdout: options.append('-i') - return docker_command(args, ['exec'] + options + [container_id] + cmd, capture=capture, stdin=stdin, stdout=stdout, interactive=interactive, - output_stream=output_stream, data=data) + return docker_command( + args, + ['exec'] + options + [container_id] + cmd, + capture=capture, + stdin=stdin, + stdout=stdout, + interactive=interactive, + output_stream=output_stream, + data=data, + ) def docker_command( @@ -983,8 +998,18 @@ def docker_command( if command[0] == 'podman' and get_podman_remote(): command.append('--remote') - return run_command(args, command + cmd, env=env, capture=capture, stdin=stdin, stdout=stdout, interactive=interactive, always=always, - output_stream=output_stream, data=data) + return run_command( + args, + command + cmd, + env=env, + capture=capture, + stdin=stdin, + stdout=stdout, + interactive=interactive, + always=always, + output_stream=output_stream, + data=data, + ) def docker_environment() -> dict[str, str]: -- cgit v1.2.1