Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring back script run status #1067

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 27 additions & 20 deletions unskript-ctl/unskript_ctl_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ def create_temp_files_of_failed_check_results(self,
return list_of_failed_files

def create_script_summary_message(self, output_metadata_file: str):
# message = ''
message = ''
if os.path.exists(output_metadata_file) is False:
self.logger.error(f"ERROR: The metadata file is missing, please check if file exists? {output_metadata_file}")
return ''
return message

metadata = ''
with open(output_metadata_file, 'r', encoding='utf-8') as f:
Expand All @@ -215,24 +215,24 @@ def create_script_summary_message(self, output_metadata_file: str):
self.logger.debug(f"\tStatus: {metadata.get('status')} \n\tTime (in seconds): {metadata.get('time_taken')} \n\tError: {metadata.get('error')} \n")

# Remove from email
# message += f'''
# <br>
# <h3> Custom Script Run Result </h3>
# <table border="1">
# <tr>
# <th> Status </th>
# <th> Time (in seconds) </th>
# <th> Error </th>
# </tr>
# <tr>
# <td>{metadata.get('status')}</td>
# <td>{metadata.get('time_taken')}</td>
# <td>{metadata.get('error')}</td>
# </tr>
# </table>
# '''

return ''
message += f'''
<br>
<h3> Custom Script Run Result </h3>
<table border="1">
<tr>
<th> Status </th>
<th> Time (in seconds) </th>
<th> Error </th>
</tr>
<tr>
<td>{metadata.get('status')}</td>
<td>{metadata.get('time_taken')}</td>
<td>{metadata.get('error')}</td>
</tr>
</table>
'''

return message

def create_info_legos_output_file(self):
"""create_info_legos_output_file: This function creates a file that will
Expand Down Expand Up @@ -469,6 +469,10 @@ def prepare_combined_email(self,
if info_result:
message += info_result
self.create_info_legos_output_file()
# print("Output Metadata File\n",output_metadata_file)
if output_metadata_file:
message += self.create_script_summary_message(output_metadata_file=output_metadata_file)
temp_attachment = self.create_email_attachment(output_metadata_file=output_metadata_file)

if len(os.listdir(self.execution_dir)) == 0 or not self.create_tarball_archive(tar_file_name=tar_file_name, output_metadata_file=None, parent_folder=parent_folder):
self.logger.error("Execution directory is empty , tarball creation unsuccessful!")
Expand Down Expand Up @@ -560,6 +564,9 @@ def send_sendgrid_notification(self,
if len(os.listdir(self.execution_dir)) == 0 or not self.create_tarball_archive(tar_file_name=tar_file_name, output_metadata_file=None, parent_folder=parent_folder):
self.logger.error("Execution directory is empty , tarball creation unsuccessful!")

if output_metadata_file:
html_message += self.create_script_summary_message(output_metadata_file=output_metadata_file)

info_result = self.create_info_gathering_action_result()
if info_result:
html_message += info_result
Expand Down
Loading