Fail early if no data is found in the database

For the run_time graph subcommand if invalid user input was recieved
and there was no data in the database we previously would continue
running until something in the data processing would raise an
exception because there was no data present. This error was often
cryptic and hard to debug. This commit fixes this by checking if
data is returned from the db api calls and if it's not then we
print an error message explaining what data was not found and
exit with a non-zero code.

Change-Id: I460679f90a46244ee0c0818bf7b3deee4cce280c
This commit is contained in:
Matthew Treinish 2015-11-24 12:30:05 -05:00
parent 7a16adcd24
commit 0a7ec50135
No known key found for this signature in database
GPG Key ID: FD12A0F214C9E177

View File

@ -36,7 +36,14 @@ def set_cli_opts(parser):
def generate_series():
session = api.get_session()
test_id = api.get_id_from_test_id(CONF.command.test_id, session)
if not test_id:
print("The test_id %s was not found in the database" %
CONF.command.test_id)
exit(2)
run_times = api.get_test_run_time_series(test_id, session)
if not run_times:
print("There was no data found in the database")
exit(3)
if not CONF.title:
test = api.get_test_by_id(test_id, session)
session.close()