[Tests] Improve RallyCliError exception

This adds cli command to RallyCliError message -
sometimes this information is helpful.

Change-Id: I05d2b036f73705a891826b5bb67b13a1723c4cfc
This commit is contained in:
Alexander Maretskiy 2016-10-10 15:12:07 +03:00
parent c0ad17725b
commit 2c9b99aee6

View File

@ -38,15 +38,19 @@ DEPLOYMENT_FILE = "/tmp/rally_functests_main_deployment.json"
class RallyCliError(Exception):
def __init__(self, code, output):
def __init__(self, cmd, code, output):
self.command = cmd
self.code = code
self.output = encodeutils.safe_decode(output)
self.msg = "Command: %s Code: %d Output: %s\n" % (self.command,
self.code,
self.output)
def __str__(self):
return "Code: %d Output: %s\n" % (self.code, self.output)
return self.msg
def __unicode__(self):
return "Code: %d Output: %s\n" % (self.code, self.output)
return self.msg
class TaskConfig(object):
@ -187,7 +191,7 @@ class Rally(object):
return json.loads(output)
return output
except subprocess.CalledProcessError as e:
raise RallyCliError(e.returncode, e.output)
raise RallyCliError(cmd, e.returncode, e.output)
def get_global(global_key, env):