Exit with non-zero status if any of the projects are not up-to-date
This commit is contained in:
parent
b2e3d431b1
commit
0d28efaebb
10
main.py
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…
Reference in New Issue