From 0d28efaebbc45905feeaba87b7a1f9f27fcad4f4 Mon Sep 17 00:00:00 2001 From: Raymond Li Date: Tue, 28 Dec 2021 21:34:10 -0500 Subject: [PATCH] Exit with non-zero status if any of the projects are not up-to-date --- main.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main.py b/main.py index f8241a7..8df0c81 100644 --- a/main.py +++ b/main.py @@ -14,6 +14,8 @@ import json if __name__ == "__main__": + exit_code = 0 + with open("data.json", "r", encoding="utf-8") as file: data = json.load(file) if sys.stdin.isatty(): @@ -37,6 +39,9 @@ if __name__ == "__main__": print(f"Success: {project} up-to-date") else: print(f"Failure: {project} out-of-sync") + + # Exit with non-zero status if any of the projects are not up-to-date + exit_code = 1 continue checker_result = project_class.check(data, project, current_time) if checker_result: @@ -46,9 +51,14 @@ if __name__ == "__main__": elif current_time - data[project]["out_of_sync_since"] \ > data[project]["out_of_sync_interval"]: print(f"Failure: {project} out-of-sync") + + # Exit with non-zero status if any of the projects are not up-to-date + exit_code = 1 continue print(f"Success: {project} up-to-date") except requests.exceptions.RequestException as err: print(f"Error: {project}\n{err}") with open("data.json", "w", encoding="utf-8") as file: json.dump(data, file, indent='\t') + + sys.exit(exit_code)