浏览代码

Handle error tasks by exiting non-zero

master
JustAnotherArchivist 1年前
父节点
当前提交
7e01aaefe2
共有 1 个文件被更改,包括 9 次插入4 次删除
  1. +9
    -4
      ia-wait-item-tasks

+ 9
- 4
ia-wait-item-tasks 查看文件

@@ -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

正在加载...
取消
保存