Skip to content

Commit

Permalink
User Reporting: Backend consistency with Jinja2
Browse files Browse the repository at this point in the history
  • Loading branch information
hujambo-dunia committed Jan 14, 2025
1 parent df75159 commit 77e1857
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
34 changes: 17 additions & 17 deletions lib/galaxy/config/templates/mail/error-report-dataset.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ <h1>Galaxy Tool Error Report</h1>
<span class="sub">
<i>from </i>
<span style="font-family: monospace;">
<a href="${host}">${host}</a>
<a href="{{ host }}">{{ host }}</a>
</span>
</span>
<h3>Error Localization</h3>
Expand All @@ -13,74 +13,74 @@ <h3>Error Localization</h3>
<tr>
<td>Dataset</td>
<td>
<a href="${hda_show_params_link}">${dataset_id} (${dataset_id_encoded})</a>
<a href="{{ hda_show_params_link }}">{{ dataset_id }} ({{ dataset_id_encoded }})</a>
</td>
</tr>
<tr style="background-color: #f2f2f2">
<td>History</td>
<td>
<a href="${history_view_link}">${history_id} (${history_id_encoded})</a>
<a href="{{ history_view_link }}">{{ history_id }} ({{ history_id_encoded }})</a>
</td>
</tr>
<tr>
<td>Failed Job</td>
<td>${hid}: ${history_item_name} (${hda_id_encoded})</td>
<td>{{ hid }}: {{ history_item_name }} ({{ hda_id_encoded }})</td>
</tr>
</tbody>
</table>
<h3>User Provided Information</h3>
The user
<span style="font-family: monospace;">${email_str}</span> provided the following information:
<span style="font-family: monospace;">{{ email_str }}</span> provided the following information:
<pre style="white-space: pre-wrap;background: #eeeeee;border:1px solid black;padding:1em;">
${message}
{{ message }}
</pre>
<h3>Detailed Job Information</h3>
Job environment and execution information is available at the job
<a href="${hda_show_params_link}">info page</a>.
<a href="{{ hda_show_params_link }}">info page</a>.
<table style="margin:1em">
<tbody>
<tr>
<td>Job ID</td>
<td>${job_id} (${job_id_encoded})</td>
<td>{{ job_id }} ({{ job_id_encoded }})</td>
</tr>
<tr style="background-color: #f2f2f2">
<td>Tool ID</td>
<td>${job_tool_id}</td>
<td>{{ job_tool_id }}</td>
</tr>
<tr>
<td>Tool Version</td>
<td>${tool_version}</td>
<td>{{ tool_version }}</td>
</tr>
<tr style="background-color: #f2f2f2">
<td>Job PID or DRM id</td>
<td>${job_runner_external_id}</td>
<td>{{ job_runner_external_id }}</td>
</tr>
<tr>
<td>Job Tool Version</td>
<td>${job_tool_version}</td>
<td>{{ job_tool_version }}</td>
</tr>
</tbody>
</table>
<h3>Job Execution and Failure Information</h3>
<h4>Command Line</h4>
<pre style="white-space: pre-wrap;background: #eeeeee;border:1px solid black;padding:1em;">
${job_command_line}
{{ job_command_line }}
</pre>
<h4>stderr</h4>
<pre style="white-space: pre-wrap;background: #eeeeee;border:1px solid black;padding:1em;">
${job_stderr}
{{ job_stderr }}
</pre>
<h4>stdout</h4>
<pre style="white-space: pre-wrap;background: #eeeeee;border:1px solid black;padding:1em;">
${job_stdout}
{{ job_stdout }}
</pre>
<h4>Job Information</h4>
<pre style="white-space: pre-wrap;background: #eeeeee;border:1px solid black;padding:1em;">
${job_info}
{{ job_info }}
</pre>
<h4>Job Traceback</h4>
<pre style="white-space: pre-wrap;background: #eeeeee;border:1px solid black;padding:1em;">
${job_traceback}
{{ job_traceback }}
</pre>
This is an automated message. Do not reply to this address.
</body>
Expand Down
12 changes: 6 additions & 6 deletions lib/galaxy/tools/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
)
from galaxy.security.validate_user_input import validate_email_str
from galaxy.util import unicodify
from galaxy.config import templates

error_report_template = open("lib/galaxy/config/templates/mail/error-report-dataset.txt", "r").read()
error_report_template_html = open("lib/galaxy/config/templates/mail/error-report-dataset.html", "r").read()
error_report_template = "mail/error-report-dataset.txt"
error_report_template_html = "mail/error-report-dataset.html"

class ErrorReporter:
def __init__(self, hda, app):
Expand Down Expand Up @@ -103,15 +104,14 @@ def create_report(self, user, email="", message="", redact_user_details_in_bugre
email_str=email_str,
message=util.unicodify(message),
)

self.report = string.Template(error_report_template).safe_substitute(report_variables)

self.report = templates.render(error_report_template, report_variables, self.app.config.templates_dir)

# 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 = templates.render(error_report_template_html, report_variables, self.app.config.templates_dir)

def _send_report(self, user, email=None, message=None, **kwd):
return self.report
Expand Down

0 comments on commit 77e1857

Please sign in to comment.