From 58ac633d801a380c9aa9338574f37849339e84d6 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 17 Feb 2023 15:27:28 +0100 Subject: [PATCH] apps: don't miserably crash when failing to read .md file such as DESCRIPTION.md --- src/app.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/app.py b/src/app.py index 8466fa604..afa0214eb 100644 --- a/src/app.py +++ b/src/app.py @@ -2088,7 +2088,12 @@ def _parse_app_doc_and_notifications(path): if pagename not in doc: doc[pagename] = {} - doc[pagename][lang] = read_file(filepath).strip() + + try: + doc[pagename][lang] = read_file(filepath).strip() + except Exception as e: + logger.error(e) + continue notifications = {} @@ -2102,7 +2107,11 @@ def _parse_app_doc_and_notifications(path): lang = m.groups()[0].strip("_") if m.groups()[0] else "en" if pagename not in notifications[step]: notifications[step][pagename] = {} - notifications[step][pagename][lang] = read_file(filepath).strip() + try: + notifications[step][pagename][lang] = read_file(filepath).strip() + except Exception as e: + logger.error(e) + continue for filepath in glob.glob(os.path.join(path, "doc", f"{step}.d") + "/*.md"): m = re.match( @@ -2114,7 +2123,12 @@ def _parse_app_doc_and_notifications(path): lang = lang.strip("_") if lang else "en" if pagename not in notifications[step]: notifications[step][pagename] = {} - notifications[step][pagename][lang] = read_file(filepath).strip() + + try: + notifications[step][pagename][lang] = read_file(filepath).strip() + except Exception as e: + logger.error(e) + continue return doc, notifications