diff --git a/services/ui_backend_service/api/log.py b/services/ui_backend_service/api/log.py index a6d01a67..22e71536 100644 --- a/services/ui_backend_service/api/log.py +++ b/services/ui_backend_service/api/log.py @@ -265,6 +265,7 @@ async def read_and_output(cache_client, task, logtype, limit=0, page=1, reverse_ return log_response["content"], log_response["pages"] + async def stream_pages(cache_client, task, logtype, output_raw): page = 1 while True: @@ -301,9 +302,10 @@ async def file_download_response(request, filename, async_line_iterator): async for lines in async_line_iterator(): await response.write(lines.encode("utf-8")) - await response.write_eof() + await response.write_eof() return response + class LogException(Exception): def __init__(self, msg='Failed to read log', id='log-error', traceback_str=None): self.message = msg diff --git a/services/ui_backend_service/data/cache/get_log_file_action.py b/services/ui_backend_service/data/cache/get_log_file_action.py index 86e3a410..70477f32 100644 --- a/services/ui_backend_service/data/cache/get_log_file_action.py +++ b/services/ui_backend_service/data/cache/get_log_file_action.py @@ -145,7 +145,7 @@ def execute(cls, if log_hash_changed or result_key not in existing_keys: def content_iter(): return log_provider.get_log_content(task, logtype) - + results[result_key] = json.dumps( paginated_result( content_iter, @@ -309,9 +309,9 @@ def paginated_result(content_iterator: Callable, page: int = 1, limit: int = 0, loglines = [] for lineno, item in enumerate(content_iterator()): _ts, line = item - if limit and lineno>(_offset+limit): + if limit and lineno > (_offset + limit): break - if _offset and lineno<_offset: + if _offset and lineno < _offset: continue loglines.append(line) loglines = "\n".join(loglines)