issue #226: test fixes.

pull/231/head
David Wilson 8 years ago
parent 6edb3f165d
commit 003f30b5a9

@ -46,7 +46,6 @@ import subprocess
import tempfile import tempfile
import time import time
import traceback import traceback
import zlib
import ansible.module_utils.json_utils import ansible.module_utils.json_utils
import ansible_mitogen.runner import ansible_mitogen.runner
@ -107,7 +106,7 @@ def _get_file(context, path, out_fp):
'is likely shutting down.', path) 'is likely shutting down.', path)
LOG.debug('target.get_file(): fetched %d bytes of %r from %r in %dms', LOG.debug('target.get_file(): fetched %d bytes of %r from %r in %dms',
metadata['size'], path, context, 1000*(time.time() - t0)) metadata['size'], path, context, 1000 * (time.time() - t0))
return ok, metadata return ok, metadata
@ -160,24 +159,24 @@ def transfer_file(context, in_path, out_path, sync=False, set_owner=False):
prefix='.ansible_mitogen_transfer-', prefix='.ansible_mitogen_transfer-',
dir=os.path.dirname(out_path)) dir=os.path.dirname(out_path))
fp = os.fdopen(fd, 'wb', mitogen.core.CHUNK_SIZE) fp = os.fdopen(fd, 'wb', mitogen.core.CHUNK_SIZE)
LOG.debug('transfer_file(out_path=%r) tempory file: %s', out_path, tmp_path) LOG.debug('transfer_file(%r) tempory file: %s', out_path, tmp_path)
try: try:
try: try:
os.fchmod(fp.fileno(), metadata['mode'])
if set_owner:
set_fd_owner(fp.fileno(), metadata['owner'], metadata['group'])
ok, metadata = _get_file(context, in_path, fp) ok, metadata = _get_file(context, in_path, fp)
if not ok: if not ok:
raise IOError('transfer of %r was interrupted.' % (in_path,)) raise IOError('transfer of %r was interrupted.' % (in_path,))
os.fchmod(fp.fileno(), metadata['mode'])
if set_owner:
set_fd_owner(fp.fileno(), metadata['owner'], metadata['group'])
finally: finally:
fp.close() fp.close()
if sync: if sync:
os.fsync(fp.fileno()) os.fsync(fp.fileno())
os.rename(tmp_path, out_path) os.rename(tmp_path, out_path)
except: except BaseException:
os.unlink(tmp_path) os.unlink(tmp_path)
raise raise
@ -456,13 +455,13 @@ def write_path(path, s, owner=None, group=None, mode=None,
if sync: if sync:
os.fsync(fp.fileno()) os.fsync(fp.fileno())
os.rename(tmp_path, out_path) os.rename(tmp_path, path)
except: except BaseException:
os.unlink(tmp_path) os.unlink(tmp_path)
raise raise
if utimes: if utimes:
os.utime(out_path, utimes) os.utime(path, utimes)
CHMOD_CLAUSE_PAT = re.compile(r'([uoga]*)([+\-=])([ugo]|[rwx]*)') CHMOD_CLAUSE_PAT = re.compile(r'([uoga]*)([+\-=])([ugo]|[rwx]*)')

Loading…
Cancel
Save