diff --git a/remind.py b/remind.py index 52ab558..cf7e8f6 100755 --- a/remind.py +++ b/remind.py @@ -1,7 +1,8 @@ import jinja2 -from smtplib import SMTP -from email.mime.text import MIMEText + from email.mime.multipart import MIMEMultipart +from email.mime.text import MIMEText +from smtplib import SMTP from functions import generate_html_file, get_osp_version, \ get_jenkins_job_info, get_bugs_dict, get_jira_dict, \ get_other_blockers diff --git a/report.py b/report.py index aeee776..bc42824 100644 --- a/report.py +++ b/report.py @@ -130,11 +130,16 @@ def run_report(config, blockers, server, header, test_email, no_email): # sort rows by descending OSP version rows = sorted(rows, key=lambda row: row['osp_version'], reverse=True) + # log and exit if no rows built - otherwise program will crash on summary generation + num_jobs = len(rows) + if num_jobs == 0: + print("No rows could be built with data for any of the jobs found with given search field. Exiting...") + return None + # initialize summary summary = {} # job result metrics - num_jobs = len(rows) summary['total_success'] = "Total SUCCESS: {}/{} = {}%".format(num_success, num_jobs, percent(num_success, num_jobs)) summary['total_unstable'] = "Total UNSTABLE: {}/{} = {}%".format(num_unstable, num_jobs, percent(num_unstable, num_jobs)) summary['total_failure'] = "Total FAILURE: {}/{} = {}%".format(num_failure, num_jobs, percent(num_failure, num_jobs))