From 0d667e82fd817487e526e435c83ee783ad1207b3 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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/teuthology/exceptions.py b/teuthology/exceptions.py index a33cec0415..b9b68db528 100644 --- a/teuthology/exceptions.py +++ b/teuthology/exceptions.py @@ -51,7 +51,12 @@ class CommandFailedError(Exception): Exception thrown on command failure """ def __init__(self, command, exitstatus, node=None, label=None): - self.command = command + if isinstance(command, (list, tuple)): + self.command = ' '.join(command) + elif instance(command, str): + self.command = command + else: + raise RuntimeError('variable "command" is not str, list or tuple') self.exitstatus = exitstatus self.node = node self.label = label