@@ -23,7 +23,7 @@ our $db = Mysql->connect ("cmshead.mps.ohio-state.edu", "ntuple", "osuT3User") o
2323
2424my %opt ;
2525Getopt::Long::Configure (" bundling" );
26- GetOptions (\%opt , " comment|c=s" , " format|f=s" , " pyConfig|p=s" , " crabCfg|b=s" , " jsonFile|j=s" , " lumiSummary|s=s" , " location|l=s" , " name|n=s" , " fileList|t=s" , " release|r=s" , " other|o" , " recipe|e=s" , " globalTag|g=s" , " configName|i=s" , " xSection|x=s" , " higherOrderXSec|y=s" , " help|h" );
26+ GetOptions (\%opt , " append|a " , " comment|c=s" , " format|f=s" , " pyConfig|p=s" , " crabCfg|b=s" , " jsonFile|j=s" , " lumiSummary|s=s" , " location|l=s" , " name|n=s" , " fileList|t=s" , " release|r=s" , " other|o" , " recipe|e=s" , " globalTag|g=s" , " configName|i=s" , " xSection|x=s" , " higherOrderXSec|y=s" , " help|h" );
2727my $argc = @ARGV ;
2828
2929printHelp ($ARGV [0]) if $opt {" help" };
9595 print " This location is already registered in the database!\n " ;
9696 exit ;
9797 }
98- dbUpdate ($id , $fullDataset , " $ENV {'USER'}\@ $ENV {'HOSTNAME'}" , $opt {" format" }, $opt {" location" }, $opt {" name" }, $opt {" fileList" }, $status , $opt {" comment" }, $opt {" pyConfig" }, $opt {" crabCfg" }, $opt {" jsonFile" }, $opt {" lumiSummary" }, $opt {" release" }, $opt {" globalTag" }, $opt {" configName" }, $opt {" xSection" }, $opt {" higherOrderXSec" }) if $ARGV [0] ne " deleteEntry" && !$opt {" other" };
98+ dbUpdate ($id , $fullDataset , " $ENV {'USER'}\@ $ENV {'HOSTNAME'}" , $opt {" format" }, $opt {" location" }, $opt {" name" }, $opt {" fileList" }, $status , $opt {" comment" }, $opt {" pyConfig" }, $opt {" crabCfg" }, $opt {" jsonFile" }, $opt {" lumiSummary" }, $opt {" release" }, $opt {" globalTag" }, $opt {" configName" }, $opt {" xSection" }, $opt {" higherOrderXSec" }, $opt { " append " } ) if $ARGV [0] ne " deleteEntry" && !$opt {" other" };
9999 dbUpdateOther ($id , $opt {" comment" }, " $ENV {'USER'}\@ $ENV {'HOSTNAME'}" ) if $ARGV [0] ne " deleteEntry" && $opt {" other" };
100100 dbDelete ($id ) if $ARGV [0] eq " deleteEntry" && !$opt {" other" };
101101 dbDeleteOther ($id ) if $ARGV [0] eq " deleteEntry" && $opt {" other" };
@@ -211,21 +211,26 @@ dbUpdate
211211 my $configName = shift ;
212212 my $xSection = shift ;
213213 my $ySection = shift ;
214-
215- $location = getLocation ($id ) if $id > 0
216- && !$crabCfgName
217- && !$comment
218- && !$format
219- && !$globalTag
220- && !$configName
221- && !$jsonFileName
222- && !$location
223- && !$name
224- && !$psetName
225- && !$release
226- && !$lumiSummaryName
227- && !$xSection
228- && !$ySection ;
214+ my $append = shift ;
215+
216+ my $oldLocation ;
217+ my $oldNFiles ;
218+ my $oldSize ;
219+ ($oldLocation , $oldNFiles , $oldSize ) = getLocation ($id ) if $id > 0;
220+ $location = $oldLocation if $oldLocation
221+ && !$crabCfgName
222+ && !$comment
223+ && !$format
224+ && !$globalTag
225+ && !$configName
226+ && !$jsonFileName
227+ && !$location
228+ && !$name
229+ && !$psetName
230+ && !$release
231+ && !$lumiSummaryName
232+ && !$xSection
233+ && !$ySection ;
229234
230235 my $user = $userAndHost ;
231236 $user =~ s / @.*$// g ;
@@ -370,11 +375,17 @@ dbUpdate
370375 }
371376 $values .= " , dataset='$name '" ;
372377 }
378+ if ($location && $append && $location ne $oldLocation )
379+ {
380+ $fullLocation = $oldLocation . " :" . $fullLocation ;
381+ $nFiles += $oldNFiles ;
382+ $size += $oldSize ;
383+ }
373384
374385 $values .= " , lastUpdateTime=now()" ;
375386 $values .= " , lastUpdateUser='$user '" ;
376387 $values .= " , format='$format '" if $format ;
377- $values .= " , location='$fullLocation '" if $location ;
388+ $values .= " , location='$fullLocation '" ;
378389 $values .= " , fileList='$fileList '" if $fileListName ;
379390 $values .= " , nFiles=$nFiles " if $nFiles ;
380391 $values .= " , sizeInGB=$size " if $size ;
@@ -479,6 +490,8 @@ printHelp
479490 print " location in the database.\n " ;
480491 print " \n " ;
481492 print " Mandatory arguments to long options are mandatory for short options too.\n " ;
493+ printf " %-29s%s \n " , " -a, --append" , " append the location given by -l to the list of" ;
494+ printf " %-29s%s \n " , " " , " locations, instead of replacing it" ;
482495 printf " %-29s%s \n " , " -b, --crabCfg FILE" , " CRAB config used to submit ntuple jobs" ;
483496 printf " %-29s%s \n " , " -c, --comment COMMENT" , " comment for the database entry" ;
484497 printf " %-29s%s \n " , " -f, --format FORMAT" , " ntuple format" ;
@@ -593,7 +606,7 @@ sizeOfDataset
593606 print " $location does not exist!\n " ;
594607 exit ;
595608 }
596- $nFiles = ` ls $location | wc -l` ;
609+ $nFiles = ` ls $location /*.root 2>/dev/null | wc -l` ;
597610 $size = ` du -s $location ` ;
598611 $size =~ s / ([^ ]*) .*/ $1 / ;
599612 $size /= 1024 * 1024;
@@ -754,7 +767,7 @@ uploadConfig
754767 }
755768 if ($release )
756769 {
757- my $query = " select id from ntupleRelease where name='$release '" ;
770+ my $query = " select id from ntupleRelease where name='$release ' and pending=0 and available=1 " ;
758771 $db -> selectdb (" ntuple" );
759772 my $results = $db -> query ($query );
760773 if ($results -> numrows () != 1)
@@ -820,10 +833,10 @@ getLocation
820833{
821834 my $id = shift ;
822835
823- my $query = " select location from ntuple where id=$id " ;
836+ my $query = " select location,nFiles,sizeInGB from ntuple where id=$id " ;
824837 $db -> selectdb (" ntuple" );
825838 my $results = $db -> query ($query );
826839 my @row = $results -> fetchrow ();
827840
828- return $row [0];
841+ return ( $row [0], $row [1], $row [2]) ;
829842}
0 commit comments