From 5f88764a91e6372b509b36b7b0a12eb7884eb014 Mon Sep 17 00:00:00 2001 From: Lorenzo Pagliai <lorenzo.pagliai@seco.com> Date: Tue, 31 Oct 2023 09:26:33 +0100 Subject: [PATCH] [REPORT] Add exception handling of incomplete job In case the LAVA job is incomplete or failed to execute 'interesting' tests on the DUT, the script handle the exception and exit --- .../confluence_create_or_update_report_page.py | 15 +++++++++++---- scripts/get_jira_open_issues.py | 0 2 files changed, 11 insertions(+), 4 deletions(-) mode change 100644 => 100755 scripts/get_jira_open_issues.py diff --git a/scripts/confluence_create_or_update_report_page.py b/scripts/confluence_create_or_update_report_page.py index 595ad2f..11b314c 100755 --- a/scripts/confluence_create_or_update_report_page.py +++ b/scripts/confluence_create_or_update_report_page.py @@ -53,6 +53,8 @@ def convert_urls_to_links(text): url_pattern = r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+' text_with_links = re.sub(url_pattern, lambda x: f'<a href="{x.group(0)}">{x.group(0).split("/")[-1]}</a>', text) return text_with_links + +# Convert LAVA report in from CSV format to XHTML def convert_csv_report_to_xhtml(input_file, page_name, lava_url, lava_token, pipeline_url, testing_page_url, manifest_url, commit, branch, link_report, output_file): # Read CSV data and convert it into a list of dictionaries csv_file = input_file @@ -82,8 +84,15 @@ def convert_csv_report_to_xhtml(input_file, page_name, lava_url, lava_token, pip # Create XML structure for the initial SW info table info_root = ET.Element('root') - # Add headings to the info table - job_id = xml_data[0]['job'] + # Get job_id if available, or exit (e.g. incomplete LAVA job) + try: + job_id = xml_data[0]['job'] + except IndexError: + # Handle the case where xml_data list is empty + print("Error: No interesting job data found in the CSV file. A retrigger of the corresponding LAVA job may be necessary.") + exit(1) + + # Add heading to the page heading = ET.SubElement(info_root, 'h2') heading.text = f'Automatic LAVA Job: {job_id}' software_info_title = ET.SubElement(info_root, 'h3') @@ -109,7 +118,6 @@ def convert_csv_report_to_xhtml(input_file, page_name, lava_url, lava_token, pip # Distro name processing parts = page_name.split('-') - print(parts) if "things" in parts: distro = "Things" elif "embedded" in parts: @@ -358,7 +366,6 @@ def main(): # Strip distro related info from page name parts = args.page_name.split('-') - print(parts) if "things" in parts[-1]: distro = parts[-1:] index = (args.page_name).find("-things") diff --git a/scripts/get_jira_open_issues.py b/scripts/get_jira_open_issues.py old mode 100644 new mode 100755 -- GitLab