Skip to content

Commit

Permalink
Fixed: missing footer upon timeout errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mnot committed Nov 5, 2023
1 parent 130d4e6 commit a7347d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion redbot/formatter/html_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def error_output(self, message: str) -> None:
"""
Something bad happened.
"""
self.output(f"<p class='error'>{message}</p>")
self.output(f"<p class='error foo'>{message}</p>")
tpl = self.templates.get_template("footer.html")
self.output(tpl.render(self.template_vars))

Expand Down
12 changes: 8 additions & 4 deletions redbot/webui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from base64 import standard_b64encode
from collections import defaultdict
from configparser import SectionProxy
from functools import partial
from functools import partial, update_wrapper
import os
from random import getrandbits
import string
Expand Down Expand Up @@ -149,10 +149,12 @@ def run_test(self) -> None:
)
continue_test = partial(self.continue_test, top_resource, formatter)
error_response = partial(self.error_response, formatter)
timeout_error = partial(self.timeout_error, formatter)
update_wrapper(timeout_error, self.timeout_error)

self.timeout = thor.schedule(
int(self.config["max_runtime"]),
self.timeout_error,
timeout_error,
top_resource.show_task_map,
)

Expand Down Expand Up @@ -337,15 +339,17 @@ def error_response(
def output(self, chunk: str) -> None:
self.exchange.response_body(chunk.encode(self.charset, "replace"))

def timeout_error(self, detail: Callable[[], str] = None) -> None:
def timeout_error(
self, formatter: Formatter, detail: Callable[[], str] = None
) -> None:
"""Max runtime reached."""
details = ""
if detail:
details = f"detail={detail()}"
self.error_log(
f"{self.get_client_id()} timeout: <{self.test_uri}> descend={self.descend} {details}"
)
self.output("<p class='error'>REDbot timeout.</p>")
formatter.error_output("REDbot timeout.")
self.exchange.response_done([])

def get_client_id(self) -> str:
Expand Down

0 comments on commit a7347d4

Please sign in to comment.