source: trunk/MagicSoft/Mars/datacenter/scripts/checkstardone@ 7232

Last change on this file since 7232 was 7232, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.8 KB
Line 
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 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2004
23#
24#
25# ========================================================================
26#
27#
28
29user=`whoami`
30source /home/$user/Mars/datacenter/scripts/sourcefile
31
32table=DataSetProcessStatus
33column=fStarFilesAvail
34date=NULL
35datetime=`date +%F-%H-%M-%S`
36year=`date +%Y`
37
38todofile=$listpath/ToDo-$table-$column.txt
39getstatuslogpath=$logpath/getstatus/checkstardone/$year
40getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
41
42scriptlogpath=$logpath/run/checkstardone/`date +%Y/%m/%d`
43if [ ! -d $scriptlogpath ]
44then
45 mkdir -pv $scriptlogpath
46 if [ ! -d $scriptlogpath ]
47 then
48 echo "could not make scriptlogpath "$scriptlogpath
49 exit
50 fi
51fi
52
53scriptlog=$scriptlogpath/checkstardone-$datetime.log
54
55date >> $scriptlog 2>&1
56
57if [ ! -d $getstatuslogpath ]
58then
59 mkdir -pv $getstatuslogpath >> $scriptlog 2>&1
60 if [ ! -d $getstatuslogpath ]
61 then
62 echo "could not make getstatuslogpath "$getstatuslogpath >> $scriptlog 2>&1
63 exit
64 fi
65fi
66
67cd $mars
68
69
70if [ -e $todofile ]
71then
72 echo "checkstardone is already running -> exit" >> $scriptlog 2>&1
73 exit
74fi
75
76echo "getting list..." >> $scriptlog 2>&1
77check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
78
79case $check0 in
80 1) echo "check0=$check0 -> everthing ok -> do step" >> $scriptlog 2>&1 ;;
81 *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1 ;;
82esac
83
84datasets=(`cat $todofile`)
85
86if [ "$datasets" = "" ]
87then
88 echo "nothing to do -> exit" >> $scriptlog 2>&1
89 rm -v $todofile >> $scriptlog 2>&1
90 rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
91 date >> $scriptlog 2>&1
92 exit
93fi
94
95echo "datasets: "${datasets[@]} #>> $scriptlog 2>&1
96
97for dataset in ${datasets[@]}
98do
99 no=`printf %08d $dataset | cut -c 0-5`
100 echo "checking files for dataset $dataset..." >> $scriptlog 2>&1
101 datasetfile=$datasetpath/$no/dataset`printf %08d $dataset`.txt
102 sequences=(`cat $datasetfile | grep Sequences | sed -e 's/SequencesOn://g' | sed -e 's/SequencesOff://g'`)
103
104 if [ "$sequences" = "" ]
105 then
106 echo "no sequences found" >> $scriptlog 2>&1
107 echo "continue with next dataset" >> $scriptlog 2>&1
108 continue
109 fi
110
111 echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
112
113 outpath=$logpath/checkstardone/$no
114 echo "outpath: "$outpath >> $scriptlog 2>&1
115 if [ ! -d $outpath ]
116 then
117 mkdir -pv $outpath >> $scriptlog 2>&1
118 if [ ! -d $outpath ]
119 then
120 echo "could not make outpath $outpath -> continue " >> $scriptlog 2>&1
121 continue
122 fi
123 fi
124
125 for sequence in ${sequences[@]}
126 do
127 check1=`root -q -b $macrospath/checkstardone.C+\(\""$sequence\""\) | tee $outpath/checkstardone-$sequence.log | grep int | sed -e 's/(int)//'`
128
129 case $check1 in
130 1) echo "check1=$check1 -> everthing ok -> continue with next sequence..." >> $scriptlog 2>&1 ;;
131 *) echo "check1=$check1 -> ERROR " >> $scriptlog 2>&1
132 echo "starfiles not available for sequence -> continue" >> $scriptlog 2>&1
133 continue 2
134 ;;
135 esac
136 done
137
138 setstatuslogpath=$logpath/setstatus/checkstardone/$no
139 if [ ! -d $setstatuslogpath ]
140 then
141 mkdir -pv $setstatuslogpath >> $scriptlog 2>&1
142 if [ ! -d $setstatuslogpath ]
143 then
144 echo "could not make setstatuslogpath "$setstatuslogpath >> $scriptlog 2>&1
145 continue
146 fi
147 fi
148 check2=`root -q -b $macrospath/setstatus.C+\("\"$dataset\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslogpath/setstatus-checkstardone-$dataset.log | grep int | sed -e 's/(int)//'`
149 case $check2 in
150 1) echo "check2=$check2 -> everthing ok, status has been set" >> $scriptlog 2>&1 ;;
151 *) echo "check2=$check2 -> ERROR -> step could not be set" >> $scriptlog 2>&1 ;;
152 esac
153done
154
155rm -v $todofile >> $scriptlog 2>&1
156rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
157
158date >> $scriptlog 2>&1
159
Note: See TracBrowser for help on using the repository browser.