Skip to content

Commit 9be927a

Browse files
committed
Remove cp
1 parent eca2257 commit 9be927a

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

plugins/modules/zos_fetch.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -627,21 +627,27 @@ def _fetch_pdse(self, src, is_binary, temp_dir=None, encoding=None):
627627
Error converting encoding of the member.
628628
"""
629629
dir_path = tempfile.mkdtemp(dir=temp_dir)
630-
cmd = "cp -B \"//'{0}'\" {1}"
631-
if not is_binary:
632-
cmd = cmd.replace(" -B", "")
633-
rc, out, err = self._run_command(cmd.format(src, dir_path))
630+
631+
copy_args = {
632+
"options": ""
633+
}
634+
635+
if is_binary:
636+
copy_args["options"] = "-B"
637+
638+
rc = datasets.copy(source=src, target=file_path, **copy_args)
639+
634640
if rc != 0:
635641
rmtree(dir_path)
636642
self._fail_json(
637643
msg=(
638644
"Error copying partitioned data set {0} to USS. Make sure it is"
639645
" not empty".format(src)
640646
),
641-
stdout=out,
642-
stderr=err,
643-
stdout_lines=out.splitlines(),
644-
stderr_lines=err.splitlines(),
647+
stdout="",
648+
stderr="Error copying partitioned data set {0} to USS. Make sure it is",
649+
stdout_lines="",
650+
stderr_lines="Error copying partitioned data set {0} to USS. Make sure it is".splitlines(),
645651
rc=rc,
646652
)
647653
if (not is_binary) and encoding:
@@ -754,21 +760,24 @@ def _fetch_mvs_data(self, src, is_binary, temp_dir=None, file_override=None, enc
754760
fd, file_path = tempfile.mkstemp(dir=temp_dir)
755761
os.close(fd)
756762

757-
cmd = "cp -B \"//'{0}'\" {1}"
758-
if not is_binary:
759-
cmd = cmd.replace(" -B", "")
763+
copy_args = {
764+
"options": ""
765+
}
766+
767+
if is_binary:
768+
copy_args["options"] = "-B"
760769

761-
rc, out, err = self._run_command(cmd.format(src, file_path))
770+
rc = datasets.copy(source=src, target=file_path, **copy_args)
762771

763772
if rc != 0:
764773
os.remove(file_path)
765774
self._fail_json(
766775
msg="Unable to copy {0} to USS".format(src),
767-
stdout=str(out),
768-
stderr=str(err),
776+
stdout="",
777+
stderr="Unable to copy {0} to USS".format(src),
769778
rc=rc,
770-
stdout_lines=str(out).splitlines(),
771-
stderr_lines=str(err).splitlines(),
779+
stdout_lines="",
780+
stderr_lines="Unable to copy {0} to USS".format(src).splitlines(),
772781
)
773782
if (not is_binary) and encoding:
774783
enc_utils = encode.EncodeUtils()

0 commit comments

Comments
 (0)