Browse Source

Handle error tasks by exiting non-zero

master
JustAnotherArchivist 1 year ago
parent
commit
7e01aaefe2
1 changed files with 9 additions and 4 deletions
  1. +9
    -4
      ia-wait-item-tasks

+ 9
- 4
ia-wait-item-tasks View File

@@ -1,9 +1,9 @@
#!/bin/bash #!/bin/bash
# Wait until an item has no outstanding tasks
# Usage: ia-wait-item-tasks IDENTIFIER
if [[ $# -ne 1 ]]
if [[ $# -ne 1 || "$1" == '-h' || "$1" == '--help' ]]
then then
echo 'Usage: ia-wait-item-tasks IDENTIFIER' echo 'Usage: ia-wait-item-tasks IDENTIFIER'
echo 'Waits until the Internet Archive item IDENTIFIER has no outstanding tasks.'
echo 'Exits non-zero if there are errored tasks'
exit 1 exit 1
fi fi


@@ -12,9 +12,14 @@ set -e
while : while :
do do
out="$(ia tasks "$1")" out="$(ia tasks "$1")"
if ! grep -Fvq ' "finished": ' <<<"${out}"
out="$(python3 -c 'import json, sys; {print(o["status"]) for o in map(json.loads, sys.stdin) if "status" in o}' <<<"${out}")"
if [[ -z "${out}" ]]
then then
break break
fi fi
if grep -Fxq 'error' <<<"${out}"
then
exit 1
fi
sleep 60 sleep 60
done done

Loading…
Cancel
Save