From 81dd0fa0ccc4e18c6d292da3ea256946979d7b8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 24 Feb 2024 18:41:11 +0100 Subject: [PATCH 1/3] Split function send_to_matrix --- tools/appslib/logging_sender.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/appslib/logging_sender.py b/tools/appslib/logging_sender.py index 9cd9c801..4cadf2e3 100644 --- a/tools/appslib/logging_sender.py +++ b/tools/appslib/logging_sender.py @@ -6,18 +6,21 @@ import logging import logging.handlers +def send_to_matrix(message: str) -> None: + if which("sendxmpppy") is None: + logging.warning("Could not send error via xmpp.") + return + subprocess.call(["sendxmpppy", message], stdout=subprocess.DEVNULL) + + class LogSenderHandler(logging.Handler): def __init__(self): logging.Handler.__init__(self) self.is_logging = False def emit(self, record): - if which("sendxmpppy") is None: - logging.warning("Could not send error via xmpp.") - return - - msg = f"[Applist builder error] {record.msg}" - subprocess.call(["sendxmpppy", msg], stdout=subprocess.DEVNULL) + msg = f"[Apps tools error] {record.msg}" + send_to_matrix(msg) @classmethod def add(cls, level=logging.ERROR): From a0a307d448d69ff5b3f51ae6d519fc148d0237d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 24 Feb 2024 18:42:58 +0100 Subject: [PATCH 2/3] Always print a message on matrix --- .../autoupdate_app_sources.py | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/tools/autoupdate_app_sources/autoupdate_app_sources.py b/tools/autoupdate_app_sources/autoupdate_app_sources.py index 32cef7c8..cc84631a 100755 --- a/tools/autoupdate_app_sources/autoupdate_app_sources.py +++ b/tools/autoupdate_app_sources/autoupdate_app_sources.py @@ -585,37 +585,38 @@ def main() -> None: if state == State.failure: apps_failed[app] = current_version, main_version # actually stores logs - result_message = "" + paste_message = "" + matrix_message = "Autoupdater just ran, here are the results:" if apps_already: - result_message += f"\n{'=' * 80}\nApps already with an update PR:" + paste_message += f"\n{'=' * 80}\nApps already with an update PR:" + matrix_message += f"\n- {len(apps_already)} pending update PRs" for app, info in apps_already.items(): - result_message += f"\n- {app}" - result_message += f" ({info[0]} -> {info[1]})" if info[1] else " (app version did not change)" + paste_message += f"\n- {app}" + paste_message += f" ({info[0]} -> {info[1]})" if info[1] else " (app version did not change)" if info[2]: - result_message += f" see {info[2]}" + paste_message += f" see {info[2]}" if apps_updated: - result_message += f"\n{'=' * 80}\nApps updated:" + paste_message += f"\n{'=' * 80}\nApps updated:" + matrix_message += f"\n- {len(apps_updated)} new apps PRs" for app, info in apps_updated.items(): - result_message += f"\n- {app}" - result_message += f" ({info[0]} -> {info[1]})" if info[1] else " (app version did not change)" + paste_message += f"\n- {app}" + paste_message += f" ({info[0]} -> {info[1]})" if info[1] else " (app version did not change)" if info[2]: - result_message += f" see {info[2]}" + paste_message += f" see {info[2]}" if apps_failed: - result_message += f"\n{'=' * 80}\nApps failed:" + paste_message += f"\n{'=' * 80}\nApps failed:" + matrix_message += f"\n- {len(apps_failed)} failed apps updates: {', '.join(apps_failed.keys())}" for app, logs in apps_failed.items(): - result_message += f"\n{'='*40}\n{app}\n{'-'*40}\n{logs[0]}\n{logs[1]}\n\n" + paste_message += f"\n{'='*40}\n{app}\n{'-'*40}\n{logs[0]}\n{logs[1]}\n\n" - if apps_failed and args.paste: - paste_url = paste_on_haste(result_message) - logging.error(textwrap.dedent(f""" - Failed to run the source auto-update for: {', '.join(apps_failed.keys())} - Please run manually the `autoupdate_app_sources.py` script on these apps to debug what is happening! - See the debug log here: {paste_url} - """)) + if args.paste: + paste_url = paste_on_haste(paste_message) + matrix_message += f"\nSee the full log here: {paste_url}" - print(result_message) + appslib.logging_sender.send_to_matrix(matrix_message) + print(paste_message) if __name__ == "__main__": From b276fb1925ce965be8573f8fe8269742a2ab3950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 24 Feb 2024 22:14:12 +0100 Subject: [PATCH 3/3] Fix for local run --- tools/autoupdate_app_sources/autoupdate_app_sources.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/autoupdate_app_sources/autoupdate_app_sources.py b/tools/autoupdate_app_sources/autoupdate_app_sources.py index cc84631a..f9297c5b 100755 --- a/tools/autoupdate_app_sources/autoupdate_app_sources.py +++ b/tools/autoupdate_app_sources/autoupdate_app_sources.py @@ -607,7 +607,7 @@ def main() -> None: if apps_failed: paste_message += f"\n{'=' * 80}\nApps failed:" - matrix_message += f"\n- {len(apps_failed)} failed apps updates: {', '.join(apps_failed.keys())}" + matrix_message += f"\n- {len(apps_failed)} failed apps updates: {', '.join(str(app) for app in apps_failed.keys())}" for app, logs in apps_failed.items(): paste_message += f"\n{'='*40}\n{app}\n{'-'*40}\n{logs[0]}\n{logs[1]}\n\n"