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

dev
Raymond Li 9 months ago
parent b2e3d431b1
commit 0d28efaebb
Signed by untrusted user: r389li
GPG Key ID: A014EA89B62BBB1B
  1. 10
      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)

Loading…
Cancel
Save