forked from wrighteagle2d/autotest2d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
result.sh
executable file
·68 lines (54 loc) · 1.32 KB
/
result.sh
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
61
62
63
64
65
66
67
#!/bin/bash
RESULT_DIR="result.d"
PARSE="../scripts/parse.awk"
PROCESS="../scripts/process.py"
cd $RESULT_DIR 2>/dev/null || exit
spinner() {
local DELAY=0.05
while [ 1 ]; do
echo -n '/' ; sleep $DELAY
echo -n '-' ; sleep $DELAY
echo -n '\' ; sleep $DELAY
echo -n '|' ; sleep $DELAY
done
}
SPINNER_PID=-1
if [ $# -le 0 ]; then
spinner &
SPINNER_PID=$!
fi
RESULT=`mktemp`
RESULT_LIST=`ls -1 | grep '[0-9]\+' | sort -n`
echo >>$RESULT
parseall() {
local TITLE="N/A"
local CACHE_DIR="cache.d"
local CACHE_FILE="$CACHE_DIR/cache"
mkdir $CACHE_DIR 2>/dev/null
touch $CACHE_FILE
chmod 777 $CACHE_DIR $CACHE_FILE 2>/dev/null
for i in $RESULT_LIST; do
if [ "$TITLE" = "N/A" ]; then
TITLE=`cat $i | grep '\<vs\>' | sed -e 's/\t//g'`
if [ -z "$TITLE" ]; then
TITLE="N/A"
fi
fi
if [ ! -f $CACHE_DIR/$i ]; then
local OUTPUT=`awk -f $PARSE $i`
if [ ! -z "$OUTPUT" ]; then
echo "$OUTPUT" >>$CACHE_FILE
touch $CACHE_DIR/$i
fi
fi
done
echo $TITLE
cat $CACHE_FILE
}
parseall | python3 $PROCESS $* >>$RESULT
if [ $SPINNER_PID -gt 0 ]; then
exec 2>/dev/null
kill $SPINNER_PID
fi
cat $RESULT
rm -f $RESULT