From 9013aa612f4a8c9981d623a9dc143900b8089017 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Wed, 9 Jun 2021 14:07:28 +0530 Subject: [PATCH] exceptions: change error message for CommandFailedError For the convenience of user, print the command that led to CommandFailedError in error message as a str than as a list or a tuple. This makes it more readable and enables the user to copy and use the command without any hassles. Signed-off-by: Rishabh Dave --- teuthology/exceptions.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/teuthology/exceptions.py b/teuthology/exceptions.py index a33cec0415..7eb84b2771 100644 --- a/teuthology/exceptions.py +++ b/teuthology/exceptions.py @@ -57,6 +57,11 @@ def __init__(self, command, exitstatus, node=None, label=None): self.label = label def __str__(self): + if isinstance(self.command, (list, tuple)): + self.command = ' '.join(self.command) + elif not isinstance(self.command, str): + raise RuntimeError('variable "command" is not str, list or tuple') + prefix = "Command failed" if self.label: prefix += " ({label})".format(label=self.label)