When moving a file between file systems of different types os.rename will
throw an exception, while shutil.move correctly handles that case.
Signed-off-by: Andrew Schoen <aschoen@redhat.com>
import os
import pexpect
import yaml
+import shutil
from cStringIO import StringIO
from tempfile import NamedTemporaryFile
try:
failures = yaml.safe_load(log)
except yaml.parser.ParserError:
- log.exception("Failed to load failure log...")
+ log.exception(
+ "Failed to parse ansible failure log: {0}".format(
+ self.failure_log.name,
+ )
+ )
if failures:
if self.ctx.archive:
raise CommandFailedError(command, status)
def _archive_failures(self):
- os.rename(
+ archive_path = "{0}/ansible_failures.yaml".format(self.ctx.archive)
+ log.info("Archiving ansible failure log at: {0}".format(
+ archive_path,
+ ))
+ shutil.move(
self.failure_log.name,
- "{0}/ansible_failures.yaml".format(self.ctx.archive)
+ archive_path
)
def _build_args(self):