From 7beee52a3f83126a42b61772c4bbca1b12be63f7 Mon Sep 17 00:00:00 2001 From: Eric Charles Date: Thu, 5 Sep 2024 14:34:44 -0700 Subject: [PATCH] protect against empty log files --- src/lsst/cmservice/handlers/script_handler.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lsst/cmservice/handlers/script_handler.py b/src/lsst/cmservice/handlers/script_handler.py index 3bcef894..178b09cf 100644 --- a/src/lsst/cmservice/handlers/script_handler.py +++ b/src/lsst/cmservice/handlers/script_handler.py @@ -522,7 +522,9 @@ async def _get_diagnostic_message( ) -> str: with open(log_url, encoding="utf-8") as fin: lines = fin.readlines() - return lines[-1] + if lines: + return lines[-1] + return "Empty log file" async def _write_script( self,