mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-05 16:04:09 -07:00
Fix 3 char indent on AnsibleModule._unsafe_writes (#19542)
This commit is contained in:
parent
388510f379
commit
ab560df15f
1 changed files with 20 additions and 20 deletions
|
@ -2116,26 +2116,26 @@ class AnsibleModule(object):
|
||||||
self.set_context_if_different(dest, context, False)
|
self.set_context_if_different(dest, context, False)
|
||||||
|
|
||||||
def _unsafe_writes(self, src, dest, exception):
|
def _unsafe_writes(self, src, dest, exception):
|
||||||
# sadly there are some situations where we cannot ensure atomicity, but only if
|
# sadly there are some situations where we cannot ensure atomicity, but only if
|
||||||
# the user insists and we get the appropriate error we update the file unsafely
|
# the user insists and we get the appropriate error we update the file unsafely
|
||||||
if exception.errno == errno.EBUSY:
|
if exception.errno == errno.EBUSY:
|
||||||
#TODO: issue warning that this is an unsafe operation, but doing it cause user insists
|
#TODO: issue warning that this is an unsafe operation, but doing it cause user insists
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
out_dest = open(dest, 'wb')
|
out_dest = open(dest, 'wb')
|
||||||
in_src = open(src, 'rb')
|
in_src = open(src, 'rb')
|
||||||
shutil.copyfileobj(in_src, out_dest)
|
shutil.copyfileobj(in_src, out_dest)
|
||||||
finally: # assuring closed files in 2.4 compatible way
|
finally: # assuring closed files in 2.4 compatible way
|
||||||
if out_dest:
|
if out_dest:
|
||||||
out_dest.close()
|
out_dest.close()
|
||||||
if in_src:
|
if in_src:
|
||||||
in_src.close()
|
in_src.close()
|
||||||
except (shutil.Error, OSError, IOError):
|
except (shutil.Error, OSError, IOError):
|
||||||
e = get_exception()
|
e = get_exception()
|
||||||
self.fail_json(msg='Could not write data to file (%s) from (%s): %s' % (dest, src, e))
|
self.fail_json(msg='Could not write data to file (%s) from (%s): %s' % (dest, src, e))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.fail_json(msg='Could not replace file: %s to %s: %s' % (src, dest, exception))
|
self.fail_json(msg='Could not replace file: %s to %s: %s' % (src, dest, exception))
|
||||||
|
|
||||||
def _read_from_pipes(self, rpipes, rfds, file_descriptor):
|
def _read_from_pipes(self, rpipes, rfds, file_descriptor):
|
||||||
data = b('')
|
data = b('')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue