Skip to content

Commit

Permalink
Replaced environment from TMP to TMPDIR as this is the tmpdir used in…
Browse files Browse the repository at this point in the history
… USS
  • Loading branch information
fernandofloresg committed Oct 4, 2024
1 parent 78df07b commit d460c42
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions plugins/modules/zos_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ def convert_encoding(self, src, encoding, remote_src):
if os.path.isdir(new_src):
try:
if remote_src:
temp_dir = tempfile.mkdtemp(prefix=os.environ['TMP'])
temp_dir = tempfile.mkdtemp(prefix=os.environ['TMPDIR'])
shutil.copytree(new_src, temp_dir, dirs_exist_ok=True)
new_src = temp_dir

Expand All @@ -1295,7 +1295,7 @@ def convert_encoding(self, src, encoding, remote_src):
else:
try:
if remote_src:
fd, temp_src = tempfile.mkstemp(dir=os.environ['TMP'])
fd, temp_src = tempfile.mkstemp(dir=os.environ['TMPDIR'])
os.close(fd)
shutil.copy(new_src, temp_src)
new_src = temp_src
Expand Down Expand Up @@ -1458,7 +1458,7 @@ def create_temp_with_lf_endings(self, src):
If the conversion fails.
"""
try:
fd, converted_src = tempfile.mkstemp(dir=os.environ['TMP'])
fd, converted_src = tempfile.mkstemp(dir=os.environ['TMPDIR'])
os.close(fd)

with open(converted_src, "wb") as converted_file:
Expand Down Expand Up @@ -2216,7 +2216,7 @@ def dump_data_set_member_to_file(data_set_member, is_binary):
DataSetMemberAttributeError
When the call to dcp fails.
"""
fd, temp_path = tempfile.mkstemp(dir=os.environ['TMP'])
fd, temp_path = tempfile.mkstemp(dir=os.environ['TMPDIR'])
os.close(fd)

copy_args = dict()
Expand Down Expand Up @@ -2707,7 +2707,7 @@ def cleanup(src_list):
A list of file paths.
"""
module = AnsibleModuleHelper(argument_spec={})
tmp_prefix = os.environ['TMP']
tmp_prefix = os.environ['TMPDIR']
tmp_dir = os.path.realpath("/" + tmp_prefix)
dir_list = glob.glob(tmp_dir + "/ansible-zos-copy-payload*")
conv_list = glob.glob(tmp_dir + "/converted*")
Expand Down Expand Up @@ -3116,7 +3116,7 @@ def normalize_line_endings(src, encoding=None):
src_tag = encoding["from"]

if src_tag != "IBM-037":
fd, converted_src = tempfile.mkstemp(dir=os.environ['TMP'])
fd, converted_src = tempfile.mkstemp(dir=os.environ['TMPDIR'])
os.close(fd)

enc_utils.uss_convert_encoding(
Expand Down Expand Up @@ -3245,7 +3245,7 @@ def run_module(module, arg_def):
content = module.params.get('content')

# Set temporary directory at os environment level
os.environ['TMP'] = f"{os.path.expanduser(module.tmpdir)}/"
os.environ['TMPDIR'] = f"{os.path.expanduser(module.tmpdir)}/"

dest_data_set = module.params.get('dest_data_set')
if dest_data_set:
Expand Down Expand Up @@ -3350,7 +3350,7 @@ def run_module(module, arg_def):
src_tag = encode.Defaults.get_default_system_charset()

# Converting the original src to a temporary one in UTF-8.
fd, converted_src = tempfile.mkstemp(dir=os.environ['TMP'])
fd, converted_src = tempfile.mkstemp(dir=os.environ['TMPDIR'])
os.close(fd)
encode_utils.uss_convert_encoding(
new_src,
Expand Down

0 comments on commit d460c42

Please sign in to comment.