From: Frank Brehm Date: Fri, 13 Dec 2019 12:39:07 +0000 (+0100) Subject: Reformatting output of error message on execution X-Git-Tag: 1.4.1~1 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=138d96f5877e3642925363534f53509628e42fcb;p=pixelpark%2Fcreate-terraform.git Reformatting output of error message on execution --- diff --git a/lib/cr_tf/handler.py b/lib/cr_tf/handler.py index 36d6f42..f361556 100644 --- a/lib/cr_tf/handler.py +++ b/lib/cr_tf/handler.py @@ -60,7 +60,7 @@ from .terraform.disk import TerraformDisk from .xlate import XLATOR -__version__ = '3.3.2' +__version__ = '3.3.3' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -2806,13 +2806,11 @@ class CreateTerraformHandler(BaseHandler): result = self.run( cmd, may_simulate=True, timeout=tf_timeout, stdout=PIPE, stderr=PIPE, check=True) except CalledProcessError as e: - msg = _("Error on executing {cmd!r}: return value {v}.").format( - cmd=e.cmd, v=e.returncode) if e.stdout: - msg += '\nOutput: {}'.format(e.stdout) + print(self.colored("Output", 'AQUA') + ':\n' + to_str(e.stdout)) if e.stderr: - msg += '\nError message: {}'.format(e.stderr) - raise ExpectedHandlerError(msg) + print(self.colored("Error message", ('BOLD', 'RED') + ':\n' + to_str(e.stderr)) + raise ExpectedHandlerError(str(e)) LOG.debug(_("Completed process:") + "\n" + str(result)) if self.existing_vms: @@ -2834,8 +2832,6 @@ class CreateTerraformHandler(BaseHandler): cmd, may_simulate=True, timeout=tf_timeout, stdout=PIPE, stderr=PIPE, check=True) except CalledProcessError as e: -# msg = _("Error on executing {cmd!r}: return value {v}.").format( -# cmd=e.cmd, v=e.returncode) if e.stdout: print(self.colored("Output", 'AQUA') + ':\n' + to_str(e.stdout)) if e.stderr: @@ -2853,13 +2849,11 @@ class CreateTerraformHandler(BaseHandler): result = self.run( cmd, may_simulate=True, timeout=tf_timeout, stdout=PIPE, stderr=PIPE, check=True) except CalledProcessError as e: - msg = _("Error on executing {cmd!r}: return value {v}.").format( - cmd=e.cmd, v=e.returncode) if e.stdout: - msg += '\nOutput: {}'.format(e.stdout) + print(self.colored("Output", 'AQUA') + ':\n' + to_str(e.stdout)) if e.stderr: - msg += '\nError message: {}'.format(e.stderr) - raise ExpectedHandlerError(msg) + print(self.colored("Error message", ('BOLD', 'RED') + ':\n' + to_str(e.stderr)) + raise ExpectedHandlerError(str(e)) LOG.debug(_("Completed process:") + "\n" + str(result)) goto = Path(os.path.relpath(self.project_dir, self.start_dir))