-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_graphs.sh
executable file
·66 lines (59 loc) · 1.81 KB
/
build_graphs.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
#!/bin/bash
############################################################
# Help #
############################################################
Help()
{
# Display Help
echo "Build graphs from SMT Queries"
echo
echo "Syntax: ./build_graphs [-h|d|n]"
echo "options:"
echo "h Print this Help."
echo "d Location of .smt2 files."
echo "j Parallel jobs to run"
echo
}
############################################################
############################################################
# Main program #
############################################################
############################################################
# Set variables
Directory="NULL"
Parallel=1
############################################################
# Process the input options. Add options as needed. #
############################################################
# Get the options
while getopts ":h:d:j:" option; do
case $option in
h) # display Help
Help
exit;;
d) # Enter a name
Directory=$OPTARG;;
j)
Parallel=$OPTARG;;
\?) # Invalid option
echo "Error: Invalid option"
exit;;
esac
done
if [ ! -d "$Directory" ]; then
echo "Directory $Directory does not exists"
echo "Please provide a viable directory"
fi
re='^[0-9]+$'
if ! [[ $Parallel =~ $re ]] ; then
echo "$Parallel is not a valid value. Must be an positive integer" >&2; exit 1
fi
if [ $Parallel -gt 1 ] ; then
if ! command -v parallel &> /dev/null
then
echo "GNU parallel is not installed. Can't run $Parallel jobs"
exit 1
else
find $Directory -name "*.smt2" | parallel --bar -j $Parallel python3 src/data_handlers/graph-builder.py
fi
fi