Changeset 12972 for trunk/DataCheck


Ignore:
Timestamp:
02/29/12 13:16:26 (13 years ago)
Author:
Daniela Dorner
Message:
introduced usage of global logfile and function sendquery
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataCheck/CheckRawData.sh

    r12933 r12972  
    11#!/bin/bash
     2
     3# this script has been written to run on La Palma on the machine data
     4#   i.e. paths are only working on this machine
     5# the script starts from the zipped files
     6#   this causes a delay until files are in the database
     7#   because they have to be rsynced and zipped first (see RsyncRawData.sh, ZipRawData.sh)
    28
    39# missing
     
    1016
    1117doupdate="yes" # update all entries
    12 #doupdate="no" # fill only entries which are not yet existing #default
     18doupdate="no" # fill only entries which are not yet existing #default
    1319
    1420source `dirname $0`/Sourcefile.sh
     
    3137then
    3238   printprocesslog "ERROR "$factpath"/fitsdump is not available."
     39   finish
     40fi
     41
     42# check if paths are available
     43if ! ls /daq/raw >/dev/null 2>&1
     44then
     45   printprocesslog "ERROR /daq/raw is not available."
     46   finish
     47fi
     48if ! ls /loc_data/raw >/dev/null 2>&1
     49then
     50   printprocesslog "ERROR /loc_data/raw is not available."
     51   finish
     52fi
     53if ! ls /loc_data/zipraw >/dev/null 2>&1
     54then
     55   printprocesslog "ERROR /loc_data/zipraw is not available."
    3356   finish
    3457fi
     
    117140     
    118141      # check if entry already exists
    119       query3="SELECT fNight FROM RunInfo WHERE Concat(fNight, '_', LPAD(fRunID, 3, 0))='"$numberfromname"'"
    120       printprocesslog "DEBUG check if entry already exists in DB. QUERY: "$query3
    121       result3=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query3"`
     142      query="SELECT fNight FROM RunInfo WHERE Concat(fNight, '_', LPAD(fRunID, 3, 0))='"$numberfromname"'"
     143      printprocesslog "DEBUG check if entry already exists in DB. QUERY: "$query
     144      #result3=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query3"`
     145      result3=`sendquery`
    122146
    123147      # only proceed with file
     
    264288      fi
    265289      # get runtype
    266       query2="SELECT fRunTypeKEY FROM RunType WHERE fRunTypeName='"$runtype"'"
    267       printprocesslog "DEBUG get run type from DB. QUERY:"$query2
    268       result2=( `/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query2"` )
     290      query="SELECT fRunTypeKEY FROM RunType WHERE fRunTypeName='"$runtype"'"
     291      printprocesslog "DEBUG get run type from DB. QUERY:"$query
     292      #result2=( `/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query2"` )
     293      result2=( `sendquery` )
    269294      if [ ${#result2} -eq 0 ]
    270295      then
     
    274299
    275300      # check if entry has already checksums
    276       query5="SELECT fNight FROM RunInfo WHERE Concat(fNight, '_', LPAD(fRunID, 3, 0))='"$numberfromname"'"
    277       query5=$query5" AND NOT ISNULL(fMd5sumRaw) AND NOT ISNULL(fMd5sumRawZip)"
    278       printprocesslog "DEBUG check if md5sums are alreay in DB. QUERY:"$query5
    279       result5=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query5"`
     301      query="SELECT fNight FROM RunInfo WHERE Concat(fNight, '_', LPAD(fRunID, 3, 0))='"$numberfromname"'"
     302      query=$query" AND NOT ISNULL(fMd5sumRaw) AND NOT ISNULL(fMd5sumRawZip)"
     303      printprocesslog "DEBUG check if md5sums are alreay in DB. QUERY:"$query
     304      #result5=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query5"`
     305      result5=`sendquery`
    280306
    281307      # get md5sums of raw and zip file
     
    305331      if [ "$result3" == "" ]
    306332      then
    307          query4="INSERT"
     333         query="INSERT"
    308334         querymid=" fNight="$runnumber", fRunID="$filenumberfromname", "
    309335         querystop=
    310336      else
    311          query4="UPDATE"
     337         query="UPDATE"
    312338         querymid=
    313339         querystop=" WHERE fNight="$runnumber" AND fRunID="$filenumberfromname
    314340      fi
    315       query4=$query4" RunInfo SET "$querymid" fRunTypeKey="${result2[1]}
     341      query=$query" RunInfo SET "$querymid" fRunTypeKey="${result2[0]}
    316342      if [ $numfitserrors -eq 0 ]
    317343      then
    318          query4=$query4", fRunStart='"$runstart"', fRunStop='"$runstop"'"
     344         query=$query", fRunStart='"$runstart"', fRunStop='"$runstop"'"
    319345         if [ "$numevents" != "" ]
    320346         then
    321             query4=$query4", fNumEvents="$numevents
     347            query=$query", fNumEvents="$numevents
    322348         fi
    323349         if [ "$roi" != "" ]
    324350         then
    325             query4=$query4", fROI="$roi
     351            query=$query", fROI="$roi
    326352         fi
    327353         if [ "$roitm" != "" ]
    328354         then
    329             query4=$query4", fROITimeMarker="$roitm
     355            query=$query", fROITimeMarker="$roitm
    330356         fi
    331357         if [ "$numphys" != "" ]
    332358         then
    333             query4=$query4", fNumPhysicsTrigger="$numphys
     359            query=$query", fNumPhysicsTrigger="$numphys
    334360         fi
    335361         if [ "$numext1" != "" ]
    336362         then
    337             query4=$query4", fNumExt1Trigger="$numext1
     363            query=$query", fNumExt1Trigger="$numext1
    338364         fi
    339365         if [ "$numext2" != "" ]
    340366         then
    341             query4=$query4", fNumExt2Trigger="$numext2
     367            query=$query", fNumExt2Trigger="$numext2
    342368         fi
    343369         if [ "$numelp" != "" ]
    344370         then
    345             query4=$query4", fNumELPTrigger="$numelp
     371            query=$query", fNumELPTrigger="$numelp
    346372         fi
    347373         if [ "$numilp" != "" ]
    348374         then
    349             query4=$query4", fNumILPTrigger="$numilp
     375            query=$query", fNumILPTrigger="$numilp
    350376         fi
    351377         if [ "$numped" != "" ]
    352378         then
    353             query4=$query4", fNumPedestalTrigger="$numped
     379            query=$query", fNumPedestalTrigger="$numped
    354380         fi
    355381         if [ "$numtime" != "" ]
    356382         then
    357             query4=$query4", fNumTimeTrigger="$numtime
     383            query=$query", fNumTimeTrigger="$numtime
    358384         fi
    359385         if [ "$numoth" != "" ]
    360386         then
    361             query4=$query4", fNumOtherTrigger="$numoth
     387            query=$query", fNumOtherTrigger="$numoth
    362388         fi
    363389      fi
    364390      if [ "$md5sum" != "" ]
    365391      then
    366          query4=$query4", fMd5sumRaw='"$md5sum"', fMd5sumRawZip='"$md5sumzip"'"
     392         query=$query", fMd5sumRaw='"$md5sum"', fMd5sumRawZip='"$md5sumzip"'"
    367393      fi
    368394      if [ "$numdrsfiles" != "" ]
    369395      then
    370          query4=$query4", fHasDrsFile="$numdrsfiles
     396         query=$query", fHasDrsFile="$numdrsfiles
    371397      fi
    372398      if [ "$step" != "" ]
    373399      then
    374          query4=$query4", fDrsStep="$step
     400         query=$query", fDrsStep="$step
    375401      fi
    376402      if [ "$compiletime" != "" ]
    377403      then
    378          query4=$query4", fCompileTime='"$compiletime"'"
     404         query=$query", fCompileTime='"$compiletime"'"
    379405      fi
    380406      if [ "$revnum" != "" ]
    381407      then
    382          query4=$query4", fRevisionNumber='"$revnum"'"
    383       fi
    384       query4=$query4", fFitsFileErrors="$numfitserrors
    385       query4=$query4" "$querystop
    386       printprocesslog "INFO insert/update entry in DB. QUERY: "$query4
    387       if ! /usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query4"
    388       then
    389          printprocesslog "ERROR insert/update of "$numfromfile" to mysql failed."
    390          finish
    391       fi
     408         query=$query", fRevisionNumber='"$revnum"'"
     409      fi
     410      query=$query", fFitsFileErrors="$numfitserrors
     411      query=$query" "$querystop
     412      printprocesslog "INFO insert/update entry in DB. QUERY: "$query
     413      # send query to DB
     414      sendquery >/dev/null
     415      #if ! /usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query4"
     416      #then
     417      #   printprocesslog "ERROR insert/update of "$numfromfile" to mysql failed."
     418      #   finish
     419      #fi
    392420   done
    393421done
Note: See TracChangeset for help on using the changeset viewer.