Browse Source

Handle error tasks by exiting non-zero

master
JustAnotherArchivist 11 months 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
# 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
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
fi

@@ -12,9 +12,14 @@ set -e
while :
do
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
break
fi
if grep -Fxq 'error' <<<"${out}"
then
exit 1
fi
sleep 60
done

Loading…
Cancel
Save