_test_run_release_test_sh.py 836 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import os
  2. import sys
  3. import click
  4. @click.command()
  5. @click.argument("state_file", type=str)
  6. @click.argument("exit_1", type=int)
  7. @click.argument("exit_2", type=int)
  8. @click.argument("exit_3", type=int)
  9. def main(
  10. state_file: str,
  11. exit_1: int,
  12. exit_2: int,
  13. exit_3: int,
  14. ):
  15. if not os.path.exists(state_file):
  16. state = 0
  17. else:
  18. with open(state_file, "rt") as fp:
  19. state = int(fp.read())
  20. state += 1
  21. with open(state_file, "wt") as fp:
  22. fp.write(str(state))
  23. if state == 1:
  24. print(f"Exiting with status: {exit_1}")
  25. sys.exit(exit_1)
  26. if state == 2:
  27. print(f"Exiting with status: {exit_2}")
  28. sys.exit(exit_2)
  29. if state == 3:
  30. print(f"Exiting with status: {exit_3}")
  31. sys.exit(exit_3)
  32. if __name__ == "__main__":
  33. main()