1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # ========================================================================
|
---|
4 | #
|
---|
5 | # *
|
---|
6 | # * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
7 | # * Software. It is distributed to you in the hope that it can be a useful
|
---|
8 | # * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
9 | # * It is distributed WITHOUT ANY WARRANTY.
|
---|
10 | # *
|
---|
11 | # * Permission to use, copy, modify and distribute this software and its
|
---|
12 | # * documentation for any purpose is hereby granted without fee,
|
---|
13 | # * provided that the above copyright notice appear in all copies and
|
---|
14 | # * that both that copyright notice and this permission notice appear
|
---|
15 | # * in supporting documentation. It is provided "as is" without express
|
---|
16 | # * or implied warranty.
|
---|
17 | # *
|
---|
18 | #
|
---|
19 | #
|
---|
20 | # Author(s): Daniela Dorner 10/2006 <mailto:dorner@astro.uni-wuerzburg.de>
|
---|
21 | #
|
---|
22 | # Copyright: MAGIC Software Development, 2000-2006
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This script checks from the DB which new starfiles have been produced
|
---|
28 | # and sends it to the person in charge for building datasets
|
---|
29 | #
|
---|
30 |
|
---|
31 | #source `dirname $0`/sourcefile
|
---|
32 | #printprocesslog "INFO starting $0"
|
---|
33 | function usage()
|
---|
34 | {
|
---|
35 | echo "Usage: $0 [options]"
|
---|
36 | echo "options:"
|
---|
37 | echo -n " --sequ sequence# "
|
---|
38 | echo -n " giving number of the sequence starting from which "
|
---|
39 | echo " sequences with star done are returned "
|
---|
40 | echo -n " --date "
|
---|
41 | echo -n " giving date starting from which sequences with star "
|
---|
42 | echo "done are returned"
|
---|
43 | echo ""
|
---|
44 | exit
|
---|
45 | }
|
---|
46 |
|
---|
47 |
|
---|
48 | while [ "$1" ]
|
---|
49 | do
|
---|
50 | case $1 in
|
---|
51 | --sequ) shift
|
---|
52 | seq=$1
|
---|
53 | echo "Only sequences starting from sequence # $seq are considered"
|
---|
54 | ;;
|
---|
55 | --date) shift
|
---|
56 | date=$1
|
---|
57 | echo "Only star starting from date $date is considered"
|
---|
58 | ;;
|
---|
59 | -h) usage
|
---|
60 | ;;
|
---|
61 | *) echo "unknown option $1 "
|
---|
62 | usage
|
---|
63 | exit
|
---|
64 | ;;
|
---|
65 | esac
|
---|
66 | shift
|
---|
67 | done
|
---|
68 |
|
---|
69 | alias mymysql='mysql -u MAGIC --password=d99swMT! --host=vela MyMagic -s -e'
|
---|
70 |
|
---|
71 | query="SELECT fSequenceFirst FROM SequenceProcessStatus WHERE NOT ISNULL(fStar) "
|
---|
72 | cond=""
|
---|
73 | if ! [ "$seq" = "" ]
|
---|
74 | then
|
---|
75 | cond=$cond" AND SequenceProcessStatus.fSequenceFirst > $seq "
|
---|
76 | fi
|
---|
77 | if ! [ "$date" = "" ]
|
---|
78 | then
|
---|
79 | cond=$cond" AND fStar > '$date'"
|
---|
80 | fi
|
---|
81 | query=$query$cond
|
---|
82 |
|
---|
83 | sequences=`mymysql " $query "`
|
---|
84 | if [ "$sequences" = "" ]
|
---|
85 | then
|
---|
86 | echo "no sequences with new star files found "
|
---|
87 | exit
|
---|
88 | fi
|
---|
89 | sequences2=`echo $sequences | sed -e 's/ /,/g'`
|
---|
90 | query="SELECT fSourceKEY FROM Sequences WHERE fSequenceFirst IN ($sequences2) GROUP BY fSourceKEY"
|
---|
91 | sources=`mymysql " $query "`
|
---|
92 | sources2=`echo $sources | sed -e 's/ /,/g'`
|
---|
93 | query="SELECT fSourceName FROM Source WHERE fSourceKEY IN ($sources2)"
|
---|
94 | sourcenames=`mymysql " $query "`
|
---|
95 | #echo "for the following sources new starfiles have been produced: $sourcenames"
|
---|
96 | #echo ""
|
---|
97 | for sourcename in $sourcenames
|
---|
98 | do
|
---|
99 | query="SELECT Sequences.fSequenceFirst FROM Sequences "
|
---|
100 | query=$query" LEFT JOIN Source ON Source.fSourceKEY=Sequences.fSourceKEY "
|
---|
101 | query=$query" LEFT JOIN SequenceProcessStatus ON SequenceProcessStatus.fSequenceFirst=Sequences.fSequenceFirst "
|
---|
102 | query=$query"WHERE fSourceName='$sourcename'"
|
---|
103 | query=$query$cond
|
---|
104 | seqspersource=`mymysql " $query "`
|
---|
105 | seqs=`echo $seqspersource | sed -e 's/ /,/g'`
|
---|
106 | printf "star done for %12s the following new sequences: %s \n" $sourcename $seqs
|
---|
107 | done
|
---|
108 |
|
---|
109 | for sourcename in $sourcenames
|
---|
110 | do
|
---|
111 | echo "searching datasets for $sourcename"
|
---|
112 | if ! grep $sourcename /magic/test/bu.2006.10.10/datasets/*/*.txt 2>/dev/null
|
---|
113 | then
|
---|
114 | echo "sorry, no dataset found for $sourcename, please create a new dataset"
|
---|
115 | fi
|
---|
116 | done
|
---|
117 |
|
---|
118 |
|
---|
119 | #nail -s 'found warnings in '$oldprocesslog $erradrs
|
---|
120 |
|
---|
121 | #printprocesslog "INFO finished $0"
|
---|
122 |
|
---|