]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Reformatting output of error message on execution
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 13 Dec 2019 12:39:07 +0000 (13:39 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 13 Dec 2019 12:39:07 +0000 (13:39 +0100)
lib/cr_tf/handler.py

index 36d6f42a4582c492031503ba3c4751add3f3c425..f3615560e1d13c1725156f8633417ac3b2eaa58a 100644 (file)
@@ -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))