5 |
# Make a table of classes and issues type "Pipeline Release Notes" |
# Make a table of classes and issues type "Pipeline Release Notes" |
6 |
# Requires that mlovccf has been run before to produce the all_ccfs.txt file |
# Requires that mlovccf has been run before to produce the all_ccfs.txt file |
7 |
# |
# |
8 |
# $Id: mtovccf,v 1.1 2015/03/10 13:28:13 ccflib Exp $ |
# $Id: mtovccf,v 1.3 2015/03/10 16:50:59 ccflib Exp $ |
9 |
|
|
10 |
VALID_CCF="/home/ccflib/valid_ccf" |
VALID_CCF="/home/ccflib/valid_ccf" |
11 |
|
|
12 |
if [ ! -f "${VALID_CCF}/all_ccfs.txt" ] ; then |
now_table=`date +'%Y-%m-%dT%H:%M:%S'` |
13 |
echo "Error: Please run first mlovccf" |
|
14 |
|
if [ -z "$1" ] ; then |
15 |
|
echo |
16 |
|
echo "Use: mtovccf all_ccfs_YYYMMDD_HHMM" |
17 |
|
echo " File all_ccfs_YYYMMDD_HHMM (without .txt ext) must be produced by mlovccf" |
18 |
|
echo |
19 |
|
exit |
20 |
|
fi |
21 |
|
|
22 |
|
all_ccfs=$1 |
23 |
|
|
24 |
|
if [ ! -f "${VALID_CCF}/${all_ccfs}.txt" ] ; then |
25 |
|
echo "Error: Cannot find ${all_ccfs}.txt in directory ${VALID_CCF}" |
26 |
exit |
exit |
27 |
fi |
fi |
28 |
|
|
29 |
|
# Make a table of classes and issues type "Pipeline Release Notes" |
30 |
|
|
31 |
# Lists all CCF classes |
# Lists all CCF classes |
32 |
|
|
33 |
ccf_classes="${VALID_CCF}/ccf_classes.txt" |
ccf_classes="${VALID_CCF}/ccf_classes.txt" |
34 |
|
|
35 |
while read line |
while read line |
36 |
do |
do |
37 |
class=`echo $line | awk -F"_" '{print $1"_"$2}'` |
class=`echo $line | awk -F"_" '{print $1"_"$2}'` |
38 |
echo $class >> ${ccf_classes} |
echo $class >> ${ccf_classes} |
39 |
done < ${VALID_CCF}/all_ccfs.txt |
done < ${VALID_CCF}/${all_ccfs}.txt |
40 |
|
|
41 |
cat ${ccf_classes} | sort -u > ${VALID_CCF}/kk.txt |
cat ${ccf_classes} | sort -u > ${VALID_CCF}/kk.txt |
42 |
mv ${VALID_CCF}/kk.txt ${ccf_classes} |
mv ${VALID_CCF}/kk.txt ${ccf_classes} |
43 |
|
|
44 |
# Output final file is named all_ccfs_table.txt |
# Output final file is named all_ccfs_${now}_table.txt |
45 |
|
|
46 |
total_number_of_ccfs=0 |
total_number_of_ccfs=0 |
47 |
|
|
48 |
all_ccfs_table="${VALID_CCF}/all_ccfs_table.txt" |
all_ccfs_table="${VALID_CCF}/${all_ccfs}_table.txt" |
49 |
|
|
50 |
[ -f "${all_ccfs_table}" ] && rm ${all_ccfs_table} |
[ -f "${all_ccfs_table}" ] && rm ${all_ccfs_table} |
51 |
|
|
52 |
now=`date +'%Y-%M-%dT%H:%M:%S'` |
echo "Table of valid CCFs at $now_table" >> ${all_ccfs_table} |
53 |
|
echo >> ${all_ccfs_table} |
54 |
|
echo "|================================|=============|=======|" >> ${all_ccfs_table} |
55 |
|
echo "| Calibration File | Issue range | Count |" >> ${all_ccfs_table} |
56 |
|
echo "|================================|=============|=======|" >> ${all_ccfs_table} |
57 |
|
|
|
echo "Table of valid CCFs at $now" >> ${all_ccfs_table} |
|
|
echo >> ${all_ccfs_table} |
|
|
echo "|================================|=============|" >> ${all_ccfs_table} |
|
|
echo "| Calibration File | Issue range |" >> ${all_ccfs_table} |
|
|
echo "|================================|=============|" >> ${all_ccfs_table} |
|
|
|
|
|
|
|
58 |
while read ccf_class |
while read ccf_class |
59 |
do |
do |
60 |
echo -n "Processing class $ccf_class ..." |
echo -n "Processing class $ccf_class ..." |
61 |
issues_file="${VALID_CCF}/ccf_issues_for_${ccf_class}.txt" |
issues_file="${VALID_CCF}/ccf_issues_for_${ccf_class}.txt" |
62 |
[ -f "${issues_file}" ] && rm ${issues_file} |
[ -f "${issues_file}" ] && rm ${issues_file} |
63 |
while read line |
while read line |
64 |
do |
do |
65 |
class=`echo $line | awk -F"_" '{print $1"_"$2}'` |
class=`echo $line | awk -F"_" '{print $1"_"$2}'` |
66 |
[ "$class" != "$ccf_class" ] && continue |
[ "$class" != "$ccf_class" ] && continue |
67 |
issue=`echo $line | awk -F"_" '{print $3}' | cut -d. -f1` |
issue=`echo $line | awk -F"_" '{print $3}' | cut -d. -f1` |
68 |
echo $issue >> ${issues_file} |
echo $issue >> ${issues_file} |
69 |
done < ${VALID_CCF}/all_ccfs.txt |
done < ${VALID_CCF}/${all_ccfs}.txt |
70 |
|
|
71 |
|
cat ${issues_file} | sort -u > kk.txt |
72 |
cat ${issues_file} | sort -u > kk.txt |
mv kk.txt ${issues_file} |
73 |
mv kk.txt ${issues_file} |
real_number_of_issues_for_this_class=`wc -l ${issues_file} | awk -F" " '{print $1}'` |
74 |
real_number_of_issues_for_this_class=`wc -l ${issues_file} | awk -F" " '{print $1}'` |
|
75 |
|
first_issue=`head -1 ${issues_file}` |
76 |
first_issue=`head -1 ${issues_file}` |
last_issue=`tail -1 ${issues_file}` |
77 |
last_issue=`tail -1 ${issues_file}` |
li=$((10#$last_issue)) |
|
|
|
|
li=$((10#$last_issue)) |
|
78 |
fi=$((10#$first_issue)) |
fi=$((10#$first_issue)) |
79 |
|
|
80 |
sequential_number_of_issues_for_this_class=$(($li - $fi + 1)) |
sequential_number_of_issues_for_this_class=$((li - fi + 1)) |
81 |
if [ "${real_number_of_issues_for_this_class}" -lt "${sequential_number_of_issues_for_this_class}" ] ; then |
|
82 |
asterisk="(*)" |
asterisk=" " |
83 |
else |
[ "${real_number_of_issues_for_this_class}" -lt "${sequential_number_of_issues_for_this_class}" ] && asterisk="(*)" |
|
asterisk=" " |
|
|
fi |
|
|
total_number_of_ccfs=$(($real_number_of_issues_for_this_class + $total_number_of_ccfs)) |
|
|
|
|
|
if [ "${first_issue}" != "${last_issue}" ] ; then |
|
|
printf "| %-30s | %4s-%4s%3s|\n" ${ccf_class} ${first_issue} ${last_issue} ${asterisk} >> ${all_ccfs_table} |
|
|
else |
|
|
printf "| %-30s | %4s |\n" ${ccf_class} ${first_issue} >> ${all_ccfs_table} |
|
|
fi |
|
|
|
|
|
echo "done" |
|
|
done < ${ccf_classes} |
|
|
|
|
|
echo "|================================|=============|" >> ${all_ccfs_table} |
|
|
echo >> ${all_ccfs_table} |
|
|
echo "(*): Some issues in the range are not required." >> ${all_ccfs_table} |
|
|
rm ${VALID_CCF}/ccf_classes.txt |
|
|
rm ${VALID_CCF}/ccf_issues_for*.txt |
|
84 |
|
|
85 |
|
total_number_of_ccfs=$((real_number_of_issues_for_this_class + total_number_of_ccfs)) |
86 |
|
|
87 |
|
rn=$real_number_of_issues_for_this_class |
88 |
|
|
89 |
echo ; echo "Number of valid CCFs required at $now : ${total_number_of_ccfs}" |
if [ "${first_issue}" != "${last_issue}" ] ; then |
90 |
|
if [ "$asterisk" = "(*)" ] ; then |
91 |
|
printf "| %-30s | %4s-%4s(*)| %4s |\n" ${ccf_class} ${first_issue} ${last_issue} ${rn} >> ${all_ccfs_table} |
92 |
|
else |
93 |
|
printf "| %-30s | %4s-%4s | %4s |\n" ${ccf_class} ${first_issue} ${last_issue} ${rn} >> ${all_ccfs_table} |
94 |
|
fi |
95 |
|
else |
96 |
|
printf "| %-30s | %4s | %4s |\n" ${ccf_class} ${first_issue} ${rn} >> ${all_ccfs_table} |
97 |
|
fi |
98 |
|
|
99 |
|
echo "done" |
100 |
|
done < ${ccf_classes} |
101 |
|
|
102 |
|
echo "|================================|=============|=======|" >> ${all_ccfs_table} |
103 |
|
echo >> ${all_ccfs_table} |
104 |
|
echo "(*): Incomplete range." >> ${all_ccfs_table} |
105 |
|
echo "" >> ${all_ccfs_table} |
106 |
|
echo "Total number of valid CCFs required : ${total_number_of_ccfs}" >> ${all_ccfs_table} |
107 |
|
rm ${VALID_CCF}/ccf_classes.txt |
108 |
|
rm ${VALID_CCF}/ccf_issues_for*.txt |