mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 11:55:04 +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:
@@ -178,7 +178,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:
|
||||
@@ -244,11 +244,13 @@ class Connection(ConnectionBase):
|
||||
try:
|
||||
with open(to_bytes(in_path, errors="surrogate_or_strict"), "rb") as in_file:
|
||||
in_data = in_file.read()
|
||||
rc, out, err = self.exec_command(cmd=["tee", out_path], in_data=in_data)
|
||||
rc, dummy_out, err = self.exec_command(
|
||||
cmd=["tee", out_path], in_data=in_data
|
||||
)
|
||||
if rc != 0:
|
||||
raise AnsibleError(f"failed to transfer file to {out_path}: {err}")
|
||||
except IOError as e:
|
||||
raise AnsibleError(f"failed to transfer file to {out_path}: {e}")
|
||||
raise AnsibleError(f"failed to transfer file to {out_path}: {e}") from e
|
||||
|
||||
def fetch_file(self, in_path, out_path):
|
||||
super().fetch_file(in_path, out_path)
|
||||
@@ -268,7 +270,9 @@ class Connection(ConnectionBase):
|
||||
) as out_file:
|
||||
out_file.write(out)
|
||||
except IOError as e:
|
||||
raise AnsibleError(f"failed to transfer file to {to_native(out_path)}: {e}")
|
||||
raise AnsibleError(
|
||||
f"failed to transfer file to {to_native(out_path)}: {e}"
|
||||
) from e
|
||||
|
||||
def close(self):
|
||||
"""terminate the connection; nothing to do here"""
|
||||
|
||||
Reference in New Issue
Block a user