-
Notifications
You must be signed in to change notification settings - Fork 1
/
cleanup_failed_feat_dirs
executable file
·61 lines (53 loc) · 1.69 KB
/
cleanup_failed_feat_dirs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
set -e
if [ "$#" -eq 0 ]; then
echo "cleanup_failed_feat_dirs expects the base directory containing .feat directories to examine."
exit 1
fi
rmforce=
if [ "$#" -eq 2 ]; then
[ "$1" = "-f" ] && rmforce=y || (echo "don't know how to interpret $1" && exit 1)
basedir="${2}"
else
basedir="${1}"
fi
l1featdirs=$( find "$basedir" -iname "*.feat" -type d )
#l1 checks (still running)
for f in ${l1featdirs}; do
if [ -f ${f}/report.html ]; then
#for L1, either an error or a message of "STILL RUNNING" would count as problematic
grep -q "Error" ${f}/report.html && errors=1 || errors=0
grep -q "STILL RUNNING" ${f}/report.html && errors=1
if [ $errors -eq 1 ]; then
echo "FEAT directory listed as having errors or STILL RUNNING: ${f}"
rmproceed=$rmforce
until [[ "$rmproceed" = [NnYy] ]]; do
read -sn1 -p " Delete? (y/n)" rmproceed
done
#rmproceed=y
if [[ "$rmproceed" == "Y" || "$rmproceed" == "y" ]]; then
echo " Now deleting $f"
rm -rf "${f}"
fi
fi
fi
done
l2featdirs=$( find "$basedir" -iname "*.gfeat" -type d )
for f in ${l2featdirs}; do
if [ -f ${f}/report.html ]; then
#grep -q "Errors occured during the analysis" ${f}/report.html && errors=1 || errors=0
grep -q "Error" ${f}/report.html && errors=1 || errors=0
grep -q "STILL RUNNING" ${f}/report.html && errors=1
if [ $errors -eq 1 ]; then
echo "GFEAT directory listed as having errors of STILL RUNNING: ${f}"
rmproceed=$rmforce
until [[ "$rmproceed" = [NnYy] ]]; do
read -sn1 -p " Delete? (y/n)" rmproceed
done
if [[ "$rmproceed" == "Y" || "$rmproceed" == "y" ]]; then
echo " Now deleting $f"
rm -rf "${f}"
fi
fi
fi
done