mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix python-2.4ism that was still present in basic.py's use of tempfile
This commit is contained in:
parent
0442efd33a
commit
3760cc3a7d
1 changed files with 4 additions and 5 deletions
|
@ -2532,17 +2532,16 @@ class AnsibleModule(object):
|
||||||
self.fail_json(msg='Could not replace file: %s to %s: %s' % (src, dest, to_native(e)),
|
self.fail_json(msg='Could not replace file: %s to %s: %s' % (src, dest, to_native(e)),
|
||||||
exception=traceback.format_exc())
|
exception=traceback.format_exc())
|
||||||
else:
|
else:
|
||||||
b_dest_dir = os.path.dirname(b_dest)
|
|
||||||
# Use bytes here. In the shippable CI, this fails with
|
# Use bytes here. In the shippable CI, this fails with
|
||||||
# a UnicodeError with surrogateescape'd strings for an unknown
|
# a UnicodeError with surrogateescape'd strings for an unknown
|
||||||
# reason (doesn't happen in a local Ubuntu16.04 VM)
|
# reason (doesn't happen in a local Ubuntu16.04 VM)
|
||||||
native_dest_dir = b_dest_dir
|
b_dest_dir = os.path.dirname(b_dest)
|
||||||
native_suffix = os.path.basename(b_dest)
|
b_suffix = os.path.basename(b_dest)
|
||||||
native_prefix = b('.ansible_tmp')
|
|
||||||
error_msg = None
|
error_msg = None
|
||||||
tmp_dest_name = None
|
tmp_dest_name = None
|
||||||
try:
|
try:
|
||||||
tmp_dest_fd, tmp_dest_name = tempfile.mkstemp(prefix=native_prefix, dir=native_dest_dir, suffix=native_suffix)
|
tmp_dest_fd, tmp_dest_name = tempfile.mkstemp(prefix=b'.ansible_tmp',
|
||||||
|
dir=b_dest_dir, suffix=b_suffix)
|
||||||
except (OSError, IOError) as e:
|
except (OSError, IOError) as e:
|
||||||
error_msg = 'The destination directory (%s) is not writable by the current user. Error was: %s' % (os.path.dirname(dest), to_native(e))
|
error_msg = 'The destination directory (%s) is not writable by the current user. Error was: %s' % (os.path.dirname(dest), to_native(e))
|
||||||
except TypeError:
|
except TypeError:
|
||||||
|
|
Loading…
Reference in a new issue