Exit with non-zero status if any of the projects are not up-to-date

This commit is contained in:
Raymond Li 2021-12-28 21:34:10 -05:00
parent b2e3d431b1
commit 0d28efaebb
Signed by: r389li
GPG Key ID: A014EA89B62BBB1B
1 changed files with 10 additions and 0 deletions

10
main.py
View File

@ -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)