Debian Codegraph @

analyzers/nst.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 #------------------------------------------------------------------------------
3 # Copyright (c) 2013 EPAM Systems
4 #------------------------------------------------------------------------------
5 #
6 # This file is part of Nfstrace.
7 #
8 # Nfstrace is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, version 2 of the License.
11 #
12 # Nfstrace is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Nfstrace. If not, see <http://www.gnu.org/licenses/>.
19 #------------------------------------------------------------------------------
20
21 usagescip-shell shell shell-project 0.0.0 usage().()
22 {
23 catscip-shell system . . cat. << EOF
24 Graph images by data provided by analyzers.
25 usage: analyzers/nst.sh -a analyzers/breakdown.plt -d . -p "breakdown*.dat"
26
27 OPTIONS:
28 -h Show this message.
29 -a Set path to the analyzer.
30 -d Directory contained i_files-files. Pattern: <analyzer>(.)*.dat
31 -f Use specific file as i_files-file.
32 -p Pattern used for file search.
33 -r Recursive search.
34 -v Verbose.
35
36 Known issues:
37 Supported just one analyzer ('-a' option) at a time.
38 EOF
39 }
40
41 i_ext=.dat
42 o_ext=.png
43
44 analyzer=
45 directories=()
46 i_files=()
47
48 while getopts “ha:d:f:p:rv” option; do
49 case "$option" in
50 h)
51 usagescip-shell shell shell-project 0.0.0 usage().
52 exit
53 ;;
54 a)
55 if [[ ! -z "$analyzer" ]] ; then
56 usagescip-shell shell shell-project 0.0.0 usage().
57 exit 1
58 fi
59
60 analyzer="$OPTARG"
61 ;;
62 d)
63 directories+=("$OPTARG")
64 ;;
65 f)
66 i_files+=("$OPTARG")
67 ;;
68 p)
69 pattern="$OPTARG"
70 ;;
71 r)
72 recursive=1
73 ;;
74 v)
75 verbose=1
76 ;;
77 ?)
78 usagescip-shell shell shell-project 0.0.0 usage().
79 exit
80 ;;
81 esac
82 done
83
84 for directory in "${directories[@]}"; do
85 for filename in "$directory/$pattern"; do
86 i_files+=("$filename")
87 done
88 done
89
90 if [[ -z "$analyzer" ]] || [[ -z "$i_files" ]] ; then
91 usagescip-shell shell shell-project 0.0.0 usage().
92 exit 1
93 fi
94
95 OIFS="${IFS}"
96 IFS=$'\n'
97 for i_file in ${i_files[@]} ; do
98 o_file="${i_file/%$i_ext/$o_ext}"
99 gnuplot -e "i_file='$i_file';o_file='$o_file'" "$analyzer$e_ext" &>/dev/nullscip-shell filesystem . . `/dev/null`.
100 result=$?
101 if [[ ! -z "$verbose" ]] ; then
102 echoscip-shell system . . echo. "gnuplot -e \"i_file='$i_file';o_file='$o_file'\" $analyzer$e_ext"
103 if [[ ! $result == 0 ]] ; then
104 echoscip-shell system . . echo. "fail during $i_file processing (return: $result)" 1>&2
105 exit 1
106 fi
107 fi
108 done
109 IFS="${OIFS}"