ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/download.sh
Revision: 1.10
Committed: Wed Jul 25 03:05:45 2012 UTC (12 years, 9 months ago) by paus
Content type: application/x-sh
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, HEAD
Changes since 1.9: +0 -8 lines
Log Message:
Preparing for new tag (Mit_029).

File Contents

# User Rev Content
1 paus 1.1 #!/bin/bash
2     #---------------------------------------------------------------------------------------------------
3     # Go through a number of download requests
4     #---------------------------------------------------------------------------------------------------
5     H=`basename $0`
6     SAMPLE_LIST=$1
7    
8 paus 1.4 # start next request
9     remainingMax=0
10    
11 paus 1.1 # health checks
12     if [ ".$1" == "." ]
13     then
14     echo "";
15     echo "usage: $H <sampleList>";
16     echo ""
17     exit 1
18     fi
19    
20     # say what we do
21     echo ""
22     echo " ==== Download queue from $SAMPLE_LIST ===="
23     echo ""
24    
25     # check that queues are really empty
26 paus 1.4 dataset="XXX"
27 paus 1.1 startTime=$(date +%s)
28     nowTime=$(date +%s); duration=$(($nowTime - $startTime))
29 paus 1.9 jobs=`condor_q -global $USER -format "%s " Cmd -format "%s \n" Args | grep $dataset | grep downloadFiles.sh | wc -l`
30 paus 1.4 while [ $jobs -gt $remainingMax ]
31 paus 1.1 do
32     echo " waiting since $duration sec == condor queue has $jobs jobs left"; sleep 60; echo ""
33 paus 1.9 jobs=`condor_q -global $USER -format "%s " Cmd -format "%s \n" Args | grep $dataset | grep downloadFiles.sh | wc -l`
34 paus 1.1 nowTime=$(date +%s); duration=$(($nowTime - $startTime))
35     done
36 paus 1.3 echo " Queues are close to empty ($jobs) -- Let's get started."
37 paus 1.1 echo ""
38    
39     # all right, ready to download
40     nSamples=`cat $SAMPLE_LIST | wc -l | cut -d ' ' -f1`
41     i=1
42     while [ $i -le $nSamples ]
43     do
44 paus 1.5 startTime=$(date +%s)
45 paus 1.1
46     line=`head -$i $SAMPLE_LIST | tail -1`
47     if [ "`echo $line | grep ^#`" != "" ]
48     then
49     i=$(( $i+1 ))
50     continue
51     fi
52    
53     # define some quantities
54 paus 1.3 baseDir=`echo $line | tr -s ' ' | cut -d ' ' -f 1`
55 paus 1.1 book=`echo $line | tr -s ' ' | cut -d ' ' -f 2`
56     version=`basename $book`
57     dataset=`echo $line | tr -s ' ' | cut -d ' ' -f 3`
58 paus 1.4 targetDir=`echo $line | tr -s ' ' | cut -d ' ' -f 4`
59 paus 1.8
60 paus 1.3 # download the sample
61 paus 1.1 downloadSample.sh $line
62    
63 paus 1.3 # go into waiting loop
64 paus 1.1 nowTime=$(date +%s); duration=$(($nowTime - $startTime))
65 paus 1.9 jobs=`condor_q -global $USER -format "%s " Cmd -format "%s \n" Args | grep $dataset | grep downloadFiles.sh | wc -l`
66 paus 1.4 while [ $jobs -gt $remainingMax ]
67 paus 1.1 do
68     echo " waiting since $duration sec == condor queue has $jobs jobs left"; sleep 60; echo ""
69 paus 1.9 jobs=`condor_q -global $USER -format "%s " Cmd -format "%s \n" Args | grep $dataset | grep downloadFiles.sh | wc -l`
70 paus 1.1 nowTime=$(date +%s); duration=$(($nowTime - $startTime))
71     done
72     echo " Queues are empty ($jobs) --> cleaning up and making catalogs."
73     echo ""
74    
75     # remove zero length files
76 paus 1.4 echo "removeZeroLengthFiles.sh $targetDir/$book/$dataset"
77     removeZeroLengthFiles.sh $targetDir/$book/$dataset
78 paus 1.1
79     # finally make the corresponding catalog
80 paus 1.8 if [ ${#version} == 3 ]
81     then
82     echo "catalog.sh -ceg $version $dataset --retry $targetDir"
83     catalog.sh -ceg $version $dataset --retry $targetDir
84     else
85     echo "This is not a normal dataset, make a simple catalog."
86     echo ""
87     list $targetDir/$book/$dataset > /tmp/list.$$
88     mkdir -p ~/catalog/t2mit/private/$book/$dataset
89     rm -f ~/catalog/t2mit/private/$book/$dataset/Files
90     touch ~/catalog/t2mit/private/$book/$dataset/Files
91     while read line
92     do
93     size=`echo $line | cut -d ' ' -f1`
94     file=`echo $line | cut -d ' ' -f2`
95     root -l -b -q $MIT_PROD_DIR/root/runSimpleFileCataloger.C\(\"$targetDir/$book/$dataset\",\"$file\"\) \
96     2> /dev/null | grep CATALOG >> ~/catalog/t2mit/private/$book/$dataset/Files
97     done < /tmp/list.$$
98     rm -f /tmp/list.$$
99     fi
100 paus 1.1
101     i=$(( $i+1 ))
102    
103     done
104    
105     exit 0