Index: trunk/MagicSoft/Mars/datacenter/scripts/sourcefile
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/sourcefile	(revision 8400)
+++ trunk/MagicSoft/Mars/datacenter/scripts/sourcefile	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -47,13 +47,13 @@
    if [ ! -d $@ ]
    then
-     mkdir -pv $@ 
-     if [ ! -d $@ ]
-     then 
-        echo "could not make dir "$@
-        rm -v $todofile
-        rm -v $lockfile
-        date
-        exit
-     fi
+      mkdir -pv $@ 
+      if [ ! -d $@ ]
+      then 
+         echo "could not make dir "$@
+         rm -v $todofile
+         rm -v $lockfile
+         date
+         exit
+      fi
    fi
 }
@@ -133,5 +133,5 @@
 function finish()
 {
-   if ls $todofile >/dev/null 2>&1
+   if ! [ "$todofile" = "" ] && ls $todofile >/dev/null 2>&1
    then 
       rm -v $todofile
@@ -160,33 +160,11 @@
    checklock0=$?
    case $checklock0 in
-       0)   echo " checklock0=$checklock0 -> continue " ;;
-       1)   echo " checklock0=$checklock0 -> file $lockfile exists -> exit"
-            date
-            exit;;
-       *)   echo " checklock0=$checklock0 -> something went completely wrong" ;;
+      0)   echo " checklock0=$checklock0 -> continue " ;;
+      1)   echo " checklock0=$checklock0 -> file $lockfile exists"
+           date
+           $@
+           exit;;
+      *)   echo " checklock0=$checklock0 -> something went completely wrong" ;;
    esac
-}
-
-# function calling the macro, which is producing the todo-list
-function getdolistroot()
-{
-   datetime=`date +%F-%H-%M-%S`
-   year=`date +%Y`
-   date=NULL
-
-   getstatuslogpath=$logpath/getstatus/$program/$year
-   getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
-   makedir $getstatuslogpath
-
-   # get todo list
-   echo "getting todo list..."
-   check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
-
-   case $check0 in
-      1)   echo " check0=$check0 -> everything ok, got todo list -> run $program";;
-      *)   echo " check0=$check0 -> ERROR -> could not get todo list -> exit"
-           finish ;;
-   esac
-
 }
 
@@ -222,26 +200,26 @@
                ;;
        stop)   case $check in
-                 ok)  echo "setstatus stop - ok"
-                      statustime="Now()"
-                      ;;
-                 no)  echo "setstatus stop - nothing new"
-                      check="ok"
-                      ;;
-                  *)  echo "setstatus stop - failed"
-                      starttime=noreset
-                      if [ "$check" == "" ]
-                      then
-                         returncode=1
-                      else
-                         returncode=$check
-                      fi
-                      failedcode=$com
-                      if ! [ "$comadd" = "" ]
-                      then
-                         failedcodeadd=$comadd
-                      fi
-                      failedtime="Now()"
-                      check="ok"
-                      ;;
+                  ok)  echo "setstatus stop - ok"
+                       statustime="Now()"
+                       ;;
+                  no)  echo "setstatus stop - nothing new"
+                       check="ok"
+                       ;;
+                   *)  echo "setstatus stop - failed"
+                       starttime=noreset
+                       if [ "$check" == "" ]
+                       then
+                          returncode=1
+                       else
+                          returncode=$check
+                       fi
+                       failedcode=$com
+                       if ! [ "$comadd" = "" ]
+                       then
+                          failedcodeadd=$comadd
+                       fi
+                       failedtime="Now()"
+                       check="ok"
+                       ;;
                esac
                ;;
@@ -250,24 +228,4 @@
                finish
                ;;
-   esac
-}
-
-# function calling the macro to set the status, after a process has finished
-function setstatusroot()
-{
-   # set status values
-   resetstatusvalues
-   evalstatus $@
-
-#   printstatusvalues
-   # set status
-   setstatuslogpath=$logpath/setstatus/$program/$var1
-   makedir $setstatuslogpath
-   setstatuslog=$setstatuslogpath/setstatus-$@-$program-$var2.log
-   checkstatus=`root -q -b $macrospath/setstatus.C+\("\"$var2\""\,"\"$table\""\,"\"$column\""\,"\"$statustime\""\,"\"$returncode\""\,"\"$failedcode\""\,"\"$failedcodeadd\""\,"\"$starttime\""\,"\"$failedtime\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
-   case $checkstatus in
-      1)   echo " checkstatus=$checkstatus -> everything ok, status has been set";;
-      *)   echo " checkstatus=$checkstatus -> ERROR -> step could not be set -> exit"
-           finish ;;
    esac
 }
@@ -417,6 +375,6 @@
    if [ "$reset" = "no" ]
    then
-      echo "YOU CAN'T RESET $column for $var2!!!"
-      printprocesslog "ERROR you can't reset $column for $var2"
+      echo "YOU CAN'T RESET $column for $primvar!!!"
+      printprocesslog "ERROR you can't reset $column for $primvar"
       finish
    fi
@@ -434,5 +392,5 @@
    fi
    query=$query", fFailedTime=$failedtime, fFailedCode=$failedcode, fFailedCodeAdd=$failedcodeadd, fReturnCode=$returncode "
-   query=$query" where $primary='$var2'"
+   query=$query" where $primary='$primvar'"
    echo " QUERY: "$query
    if ! mysql -s -u $us --password=$pw --host=vela $db -e " $query "
@@ -445,2 +403,19 @@
 }
 
+# function to send a mysql query
+function sendquery()
+{
+   getdbsetup
+   if ! val=`mysql -s -u $us --password=$pw --host=vela $db -e " $query "`
+   then
+      printprocesslog "ERROR could not query db (program: $program, function sendquery)"
+      return 1
+   fi
+   if [ "$val" = "NULL" ]
+   then
+      val=
+   fi
+   echo $val
+   return 0
+}
+
