Index: trunk/MagicSoft/Mars/datacenter/scripts/dodatacheck
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/dodatacheck	(revision 7909)
+++ trunk/MagicSoft/Mars/datacenter/scripts/dodatacheck	(revision 7910)
@@ -28,6 +28,5 @@
 # checked
 #
-# After checking, if the script is already running, the todolist is 
-# written 
+# Get todo file
 # Then for each run the following steps are done: 
 #  - filldotraw.C
@@ -40,14 +39,11 @@
 #
 
+source `dirname $0`/sourcefile
 program=datacheck
-source `dirname $0`/sourcefile
+column=fDataCheckDone
 
 set -C
 
-column=fDataCheckDone
-
-lockfile=$lockpath/lock-getting-$program-list.txt
-
-scriptlogpath=$logpath/run/$program/`date +%Y/%m`
+scriptlogpath=$logpath/run/$program/`date +%Y/%m/%d`
 makedir $scriptlogpath
 scriptlog=$scriptlogpath/$program-$datetime.log
@@ -55,51 +51,30 @@
 date >> $scriptlog 2>&1
 
-# check if there are already todo files
-echo "checking if other todo-files are there" >> $scriptlog 2>&1
-if  ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
+# get todo file
+possibletodofiles=`ls -r $listpath/ToDo-*-$column-*.txt`  >> $scriptlog 2>&1
+if [ "$possibletodofiles" = "" ]
 then 
-   echo "other file(s) on disk " >> $scriptlog 2>&1
-   echo " -> choose one file and start $program " >> $scriptlog 2>&1
+   echo "ERROR: in $program no todofiles found => something went wrong in jobmanager"
+   finish >> $scriptlog 2>&1
 else
-   # check if getting of list is already running
-   checklock "getting list of" >> $scriptlog 2>&1
-   # get todo list
-   gettodolist  >> $scriptlog 2>&1
-   rm -v $lockfile >> $scriptlog 2>&1
+   singleprocess="yes"
+   echo "todofiles: "${possibletodofiles[@]} >> $scriptlog 2>&1
+   for possibletodofile in ${possibletodofiles[@]}
+   do 
+      if ! ls $possibletodofile >> $scriptlog 2>&1
+      then 
+         echo "file is not on disk -> continue" >> $scriptlog 2>&1
+         continue
+      fi
+      lockfile=`echo $possibletodofile | sed -e 's/lists/locks/' -e 's/ToDo/lock/'`
+      checklock >> $scriptlog 2>&1
+      todofile=$possibletodofile
+   done
 fi
-
-
-# finding a todo file
-nr=bla
-echo "finding the right todo-file" >> $scriptlog 2>&1
-todofiles=`ls -r $listpath/ToDo-$table-$column-*`
-
-echo "todofiles: "${todofiles[@]} >> $scriptlog 2>&1
-for todofile in ${todofiles[@]}
-do 
-   if ! ls $todofile >> $scriptlog 2>&1
-   then 
-      echo "file is not on disk -> continue" >> $scriptlog 2>&1
-      continue
-   fi
-   lockfile=`echo $todofile | sed -e 's/lists/locks/' -e 's/ToDo/lock/'`
-   date > $lockfile >> $scriptlog 2>&1
-   checklock=$?
-   case $checklock in 
-       0)   echo "checklock=$checklock -> setting number" >> $scriptlog 2>&1
-            nr=${i}
-            break;;
-       1)   echo "checklock=$checklock -> file exists -> continue" >> $scriptlog 2>&1;;
-       *)   echo "checklock=$checklock -> something went completely wrong" >> $scriptlog 2>&1;;
-   esac
-done
-
-case $nr in
-   bla)      echo "everything is beeing processed -> exit" >> $scriptlog 2>&1
-             date  >> $scriptlog 2>&1
-             exit;;
-   12345678) echo "process nr: "$nr >> $scriptlog 2>&1;;
-esac
-
+if [ "$todofile" = "" ]
+then 
+   echo "no todofile found -> exit"  >> $scriptlog 2>&1
+   finish >> $scriptlog 2>&1
+fi
 
 # get run(s) from todo file
@@ -125,27 +100,25 @@
    echo "rawfile: "$rawfile >> $scriptlog 2>&1
    date=`echo $rawfile | cut -c 22-31`
-   echo "date: "$date >> $scriptlog 2>&1
    # for sinope the date is needed in the format YYYY-MM-DD
    date2=`echo $date | sed -e 's/\//-/g'`
-   echo "date2: "$date2 >> $scriptlog 2>&1
+
+   setstatus "start" >> $scriptlog 2>&1
 
    # running filldotraw
+   echo "doing filldotraw..." >> $scriptlog 2>&1
    filldotrawpath=$logpath/filldotraw/$date
    makedir $filldotrawpath >> $scriptlog 2>&1
    filldotrawlogfile=$filldotrawpath/filldotraw-$no2.log
 
-   echo "doing filldotraw..." >> $scriptlog 2>&1
-   setstatus "start" >> $scriptlog 2>&1
-
    check1=`root -q -b $macrospath/filldotraw.C+\("\"$rawfile\""\,kFALSE\) | tee $filldotrawlogfile | grep int | sed -e 's/.*(int)//'`
 
    case $check1 in 
-      1)   echo "check1=$check1 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
+      1)   echo " check1=$check1 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
            ;;
-      0)   echo "check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
+      0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
            check="no"
            setstatus "stop" >> $scriptlog 2>&1
            continue ;;
-      *)   echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
+      *)   echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
            com=$Ffillraw
            check=$check1
@@ -159,9 +132,7 @@
    
    sins=( "-dat"  "-cal")
-   echo ${sins[@]} >> $scriptlog 2>&1
    for sin in ${sins[@]}
    do 
       sinopefile=sinope$sin$no2
-      echo $sinopefile >> $scriptlog 2>&1
       
       echo "running sinope $sin..." >> $scriptlog 2>&1
@@ -170,7 +141,7 @@
       
       case $check2 in 
-          0)   echo "check2=$check2 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
+          0)   echo " check2=$check2 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
                ;;
-          *)   echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
+          *)   echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
                com=$Fsinope
 #               comadd=
@@ -191,11 +162,11 @@
 
    case $check3 in 
-      1)   echo "check3=$check3 -> everything ok -> set status..." >> $scriptlog 2>&1
+      1)   echo " check3=$check3 -> everything ok -> set status..." >> $scriptlog 2>&1
            ;;
-      0)   echo "check3=$check3 -> no connection to db -> continue..." >> $scriptlog 2>&1 
+      0)   echo " check3=$check3 -> no connection to db -> continue..." >> $scriptlog 2>&1 
            check="no"
            setstatus "stop" >> $scriptlog 2>&1
            continue ;;
-      *)   echo "check3=$check3 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
+      *)   echo " check3=$check3 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
            com=$Ffillsinope
            check=$check3
@@ -207,5 +178,4 @@
    echo "resetting the status for fExclusionsDone for date $date2" >> $scriptlog 2>&1
    resetlogpath=$logpath/resetexclusions/$date
-   echo "resetlogpath: $resetlogpath" >> $scriptlog 2>&1
    makedir $resetlogpath >> $scriptlog 2>&1
    resetlog=$resetlogpath/reset-exclusions-$no2-$date2.log
@@ -213,11 +183,11 @@
    check5=`root -q -b $macrospath/resetcolumn.C+\("\"fExclusionsDone\""\,"\"SequenceBuildStatus\""\,"\"$date2\""\,"\"$date2\""\,kFALSE\) | tee $resetlog | grep int | sed -e 's/(int)//'`
    case $check5 in
-      1)   echo "check5=$check5 -> everything ok, fExclusions have been reset " >> $scriptlog 2>&1
+      1)   echo " check5=$check5 -> everything ok, fExclusions have been reset " >> $scriptlog 2>&1
            ;;
-      0)   echo "check5=$check5 -> no connection to db -> continue..." >> $scriptlog 2>&1 
+      0)   echo " check5=$check5 -> no connection to db -> continue..." >> $scriptlog 2>&1 
            check="no"
            setstatus "stop" >> $scriptlog 2>&1
            continue ;;
-      *)   echo "check5=$check5 -> ERROR -> step could not be resetted -> repeat step " >> $scriptlog 2>&1
+      *)   echo " check5=$check5 -> ERROR -> step could not be resetted -> repeat step " >> $scriptlog 2>&1
            com=$Fresetexcl
            comadd=`echo $date2 | sed -e 's/-//g'`
@@ -228,5 +198,4 @@
 
    # set status
-   echo "inserting the status for the $program for run $run into the db" >> $scriptlog 2>&1
    statustime="Now()"
    failed="NULL"
