mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 03:46:55 +00:00
Python code modernization, 5/n (#1165)
* Address raise-missing-from. * Address simplifiable-if-expression. * Address unnecessary-dunder-call. * Address unnecessary-pass. * Address use-list-literal. * Address unused-variable. * Address use-dict-literal.
This commit is contained in:
@@ -167,8 +167,8 @@ class Connection(ConnectionBase):
|
||||
else:
|
||||
try:
|
||||
self.docker_cmd = get_bin_path("docker")
|
||||
except ValueError:
|
||||
raise AnsibleError("docker command not found in PATH")
|
||||
except ValueError as exc:
|
||||
raise AnsibleError("docker command not found in PATH") from exc
|
||||
|
||||
@staticmethod
|
||||
def _sanitize_version(version):
|
||||
@@ -426,7 +426,7 @@ class Connection(ConnectionBase):
|
||||
)
|
||||
|
||||
chunks = b""
|
||||
for key, event in events:
|
||||
for key, dummy_event in events:
|
||||
if key.fileobj == p.stdout:
|
||||
chunk = p.stdout.read()
|
||||
if chunk:
|
||||
@@ -523,10 +523,10 @@ class Connection(ConnectionBase):
|
||||
p = subprocess.Popen(
|
||||
args, stdin=in_file, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||
)
|
||||
except OSError:
|
||||
except OSError as exc:
|
||||
raise AnsibleError(
|
||||
"docker connection requires dd command in the container to put files"
|
||||
)
|
||||
) from exc
|
||||
stdout, stderr = p.communicate()
|
||||
|
||||
if p.returncode != 0:
|
||||
@@ -588,10 +588,10 @@ class Connection(ConnectionBase):
|
||||
stdout=out_file,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
except OSError:
|
||||
except OSError as exc:
|
||||
raise AnsibleError(
|
||||
"docker connection requires dd command in the container to put files"
|
||||
)
|
||||
) from exc
|
||||
stdout, stderr = pp.communicate()
|
||||
|
||||
if pp.returncode != 0:
|
||||
|
||||
Reference in New Issue
Block a user