The little things give you away... A collection of various small helper stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

26 lines
539 B

  1. #!/bin/bash
  2. if [[ $# -ne 1 || "$1" == '-h' || "$1" == '--help' ]]
  3. then
  4. echo 'Usage: ia-wait-item-tasks IDENTIFIER'
  5. echo 'Waits until the Internet Archive item IDENTIFIER has no outstanding tasks.'
  6. echo 'Exits non-zero if there are errored tasks'
  7. exit 1
  8. fi
  9. set -e
  10. while :
  11. do
  12. out="$(ia tasks "$1")"
  13. out="$(python3 -c 'import json, sys; {print(o["status"]) for o in map(json.loads, sys.stdin) if "status" in o}' <<<"${out}")"
  14. if [[ -z "${out}" ]]
  15. then
  16. break
  17. fi
  18. if grep -Fxq 'error' <<<"${out}"
  19. then
  20. exit 1
  21. fi
  22. sleep 60
  23. done