From d2c01903a632ccc10e59bc31640991c50ad7b164 Mon Sep 17 00:00:00 2001 From: hujambo-dunia Date: Thu, 25 Apr 2024 12:34:29 -0400 Subject: [PATCH] Added front-end email template files (removed back-end email templating strings) --- .../tools/email_templates/errors_dataset.html | 66 +++++++++ .../tools/email_templates/errors_dataset.txt | 44 ++++++ lib/galaxy/tools/errors.py | 132 ++---------------- 3 files changed, 124 insertions(+), 118 deletions(-) create mode 100644 lib/galaxy/tools/email_templates/errors_dataset.html create mode 100644 lib/galaxy/tools/email_templates/errors_dataset.txt diff --git a/lib/galaxy/tools/email_templates/errors_dataset.html b/lib/galaxy/tools/email_templates/errors_dataset.html new file mode 100644 index 000000000000..3d4e44ef73e2 --- /dev/null +++ b/lib/galaxy/tools/email_templates/errors_dataset.html @@ -0,0 +1,66 @@ + + +

Galaxy Tool Error Report

+from ${host} + +

Error Localization

+ + + + + + +
Dataset${dataset_id} (${dataset_id_encoded})
History${history_id} (${history_id_encoded})
Failed Job${hid}: ${history_item_name} (${hda_id_encoded})
+ +

User Provided Information

+ +The user ${email_str} provided the following information: + +
+${message}
+
+ + +

Detailed Job Information

+ +Job environment and execution information is available at the job info page. + + + + + + + + + +
Job ID${job_id} (${job_id_encoded})
Tool ID${job_tool_id}
Tool Version${tool_version}
Job PID or DRM id${job_runner_external_id}
Job Tool Version${job_tool_version}
+ +

Job Execution and Failure Information

+ +

Command Line

+
+${job_command_line}
+
+ +

stderr

+
+${job_stderr}
+
+ +

stdout

+
+${job_stdout}
+
+ +

Job Information

+
+${job_info}
+
+ +

Job Traceback

+
+${job_traceback}
+
+ +This is an automated message. Do not reply to this address. + diff --git a/lib/galaxy/tools/email_templates/errors_dataset.txt b/lib/galaxy/tools/email_templates/errors_dataset.txt new file mode 100644 index 000000000000..d1c90ce1cb0a --- /dev/null +++ b/lib/galaxy/tools/email_templates/errors_dataset.txt @@ -0,0 +1,44 @@ +GALAXY TOOL ERROR REPORT +------------------------ + +This error report was sent from the Galaxy instance hosted on the server +"${host}" +----------------------------------------------------------------------------- +This is in reference to dataset id ${dataset_id} (${dataset_id_encoded}) from history id ${history_id} (${history_id_encoded}) +----------------------------------------------------------------------------- +You should be able to view the history containing the related history item (${hda_id_encoded}) + +${hid}: ${history_item_name} + +by logging in as a Galaxy admin user to the Galaxy instance referenced above +and pointing your browser to the following link. + +${history_view_link} +----------------------------------------------------------------------------- +The user ${email_str} provided the following information: + +${message} +----------------------------------------------------------------------------- +info url: ${hda_show_params_link} +job id: ${job_id} (${job_id_encoded}) +tool id: ${job_tool_id} +tool version: ${tool_version} +job pid or drm id: ${job_runner_external_id} +job tool version: ${job_tool_version} +----------------------------------------------------------------------------- +job command line: +${job_command_line} +----------------------------------------------------------------------------- +job stderr: +${job_stderr} +----------------------------------------------------------------------------- +job stdout: +${job_stdout} +----------------------------------------------------------------------------- +job info: +${job_info} +----------------------------------------------------------------------------- +job traceback: +${job_traceback} +----------------------------------------------------------------------------- +(This is an automated message). diff --git a/lib/galaxy/tools/errors.py b/lib/galaxy/tools/errors.py index e6d3a79429f1..32b47f8c1eae 100644 --- a/lib/galaxy/tools/errors.py +++ b/lib/galaxy/tools/errors.py @@ -2,8 +2,10 @@ Functionality for dealing with tool errors. """ +import os import string +import jinja2 import markupsafe from galaxy import ( @@ -13,122 +15,6 @@ from galaxy.security.validate_user_input import validate_email_str from galaxy.util import unicodify -error_report_template = """ -GALAXY TOOL ERROR REPORT ------------------------- - -This error report was sent from the Galaxy instance hosted on the server -"${host}" ------------------------------------------------------------------------------ -This is in reference to dataset id ${dataset_id} (${dataset_id_encoded}) from history id ${history_id} (${history_id_encoded}) ------------------------------------------------------------------------------ -You should be able to view the history containing the related history item (${hda_id_encoded}) - -${hid}: ${history_item_name} - -by logging in as a Galaxy admin user to the Galaxy instance referenced above -and pointing your browser to the following link. - -${history_view_link} ------------------------------------------------------------------------------ -The user ${email_str} provided the following information: - -${message} ------------------------------------------------------------------------------ -info url: ${hda_show_params_link} -job id: ${job_id} (${job_id_encoded}) -tool id: ${job_tool_id} -tool version: ${tool_version} -job pid or drm id: ${job_runner_external_id} -job tool version: ${job_tool_version} ------------------------------------------------------------------------------ -job command line: -${job_command_line} ------------------------------------------------------------------------------ -job stderr: -${job_stderr} ------------------------------------------------------------------------------ -job stdout: -${job_stdout} ------------------------------------------------------------------------------ -job info: -${job_info} ------------------------------------------------------------------------------ -job traceback: -${job_traceback} ------------------------------------------------------------------------------ -(This is an automated message). -""" - -error_report_template_html = """ - - -

Galaxy Tool Error Report

-from ${host} - -

Error Localization

- - - - - - -
Dataset${dataset_id} (${dataset_id_encoded})
History${history_id} (${history_id_encoded})
Failed Job${hid}: ${history_item_name} (${hda_id_encoded})
- -

User Provided Information

- -The user ${email_str} provided the following information: - -
-${message}
-
- - -

Detailed Job Information

- -Job environment and execution information is available at the job info page. - - - - - - - - - -
Job ID${job_id} (${job_id_encoded})
Tool ID${job_tool_id}
Tool Version${tool_version}
Job PID or DRM id${job_runner_external_id}
Job Tool Version${job_tool_version}
- -

Job Execution and Failure Information

- -

Command Line

-
-${job_command_line}
-
- -

stderr

-
-${job_stderr}
-
- -

stdout

-
-${job_stdout}
-
- -

Job Information

-
-${job_info}
-
- -

Job Traceback

-
-${job_traceback}
-
- -This is an automated message. Do not reply to this address. - -""" - class ErrorReporter: def __init__(self, hda, app): @@ -218,14 +104,18 @@ def create_report(self, user, email="", message="", redact_user_details_in_bugre message=util.unicodify(message), ) - self.report = string.Template(error_report_template).safe_substitute(report_variables) + self.report = string.Template(self.get_report_template("errors_dataset", "txt")).safe_substitute( + report_variables + ) # Escape all of the content for use in the HTML report for parameter in report_variables.keys(): if report_variables[parameter] is not None: report_variables[parameter] = markupsafe.escape(unicodify(report_variables[parameter])) - self.html_report = string.Template(error_report_template_html).safe_substitute(report_variables) + self.html_report = string.Template(self.get_report_template("errors_dataset", "html")).safe_substitute( + report_variables + ) def _send_report(self, user, email=None, message=None, **kwd): return self.report @@ -235,6 +125,12 @@ def send_report(self, user, email=None, message=None, **kwd): self.create_report(user, email=email, message=message, **kwd) return self._send_report(user, email=email, message=message, **kwd) + def get_report_template(self, report_type, report_format): + path = os.path.abspath(os.path.join(os.path.dirname(__file__), "email_templates")) + env = jinja2.Environment(loader=jinja2.FileSystemLoader(path)) + template = env.get_template(report_type + "." + report_format) + return template.render() + class EmailErrorReporter(ErrorReporter): def _send_report(self, user, email=None, message=None, **kwd):