12 |
|
sub dbDeleteOther; |
13 |
|
sub addSlashes; |
14 |
|
sub uploadRelease; |
15 |
+ |
sub downloadRelease; |
16 |
|
sub datasetExists; |
17 |
|
|
18 |
|
our $db = Mysql->connect ("cmshead.mps.ohio-state.edu", "ntuple", "osuT3User") or die "Failed to connect to Tier 3, stopped"; |
24 |
|
|
25 |
|
printHelp ($ARGV[0]) if $opt{"help"}; |
26 |
|
printHelp () if $argc != 2 && $ARGV[0] ne "createOther"; |
27 |
< |
printHelp () if $ARGV[0] ne "create" && $ARGV[0] ne "createOther" && $ARGV[0] ne "update" && $ARGV[0] ne "finish" && $ARGV[0] ne "deprecate" && $ARGV[0] ne "uploadRelease" && $ARGV[0] ne "deleteEntry"; |
27 |
< |
if ($ARGV[0] eq "create" && datasetExists ($ARGV[1])) |
28 |
< |
{ |
29 |
< |
print "Dataset name already exists in the database!\n"; |
30 |
< |
exit; |
31 |
< |
} |
27 |
> |
printHelp () if $ARGV[0] ne "create" && $ARGV[0] ne "createOther" && $ARGV[0] ne "update" && $ARGV[0] ne "finish" && $ARGV[0] ne "deprecate" && $ARGV[0] ne "uploadRelease" && $ARGV[0] ne "downloadRelease" && $ARGV[0] ne "deleteEntry"; |
28 |
|
if (($ARGV[0] eq "create" || $ARGV[0] eq "finish") && !$opt{"location"}) |
29 |
|
{ |
30 |
|
print "The directory containing the ntuples must be given!\n"; |
44 |
|
$cmsswRelease =~ s/^.*CMSSW_([^\/]*).*$/CMSSW_$1/; |
45 |
|
`tar -C $parentDir -czf $ARGV[1].tar.gz $opt{"release"}`; |
46 |
|
$opt{"format"} = "BEAN" if !$opt{"format"}; |
47 |
< |
uploadRelease ($opt{"format"}, $cmsswRelease, "$ARGV[1].tar.gz", $opt{"pyConfig"}, $ARGV[1], $ENV{"USER"}, $opt{"comment"}); |
47 |
> |
uploadRelease ($opt{"format"}, $cmsswRelease, "$ARGV[1].tar.gz", $opt{"pyConfig"}, $ARGV[1], "$ENV{'USER'}", $opt{"comment"}); |
48 |
> |
} |
49 |
> |
elsif ($ARGV[0] eq "downloadRelease") |
50 |
> |
{ |
51 |
> |
downloadRelease ($ARGV[1], $opt{"pyConfig"}); |
52 |
|
} |
53 |
|
elsif ($ARGV[0] eq "createOther") |
54 |
|
{ |
56 |
|
@listOfFiles = reverse (@listOfFiles); |
57 |
|
pop (@listOfFiles); |
58 |
|
@listOfFiles = reverse (@listOfFiles); |
59 |
< |
dbOtherCreate ($ENV{"USER"}, \@listOfFiles, $opt{"comment"}); |
59 |
> |
dbOtherCreate ("$ENV{'USER'}", \@listOfFiles, $opt{"comment"}); |
60 |
|
} |
61 |
|
else |
62 |
|
{ |
70 |
|
$status = "" if $ARGV[0] eq "update"; |
71 |
|
$status = "deprecated" if $ARGV[0] eq "deprecate"; |
72 |
|
$opt{"format"} = "BEAN" if $ARGV[0] eq "create" && !$opt{"format"}; |
73 |
< |
dbUpdate ($id, $fullDataset, $ENV{"USER"}, $opt{"format"}, $opt{"location"}, $opt{"fileList"}, $status, $opt{"comment"}, $opt{"pyConfig"}, $opt{"crabCfg"}, $opt{"jsonFile"}, $opt{"lumiSummary"}, $opt{"release"}) if !$opt{"other"}; |
74 |
< |
dbUpdateOther ($id, $opt{"comment"}) if $opt{"other"}; |
73 |
> |
dbUpdate ($id, $fullDataset, "$ENV{'USER'}\@$ENV{'HOSTNAME'}", $opt{"format"}, $opt{"location"}, $opt{"fileList"}, $status, $opt{"comment"}, $opt{"pyConfig"}, $opt{"crabCfg"}, $opt{"jsonFile"}, $opt{"lumiSummary"}, $opt{"release"}) if !$opt{"other"}; |
74 |
> |
dbUpdateOther ($id, $opt{"comment"}, "$ENV{'USER'}\@$ENV{'HOSTNAME'}") if $opt{"other"}; |
75 |
|
dbDelete ($id) if $ARGV[0] eq "deleteEntry" && !$opt{"other"}; |
76 |
|
dbDeleteOther ($id) if $ARGV[0] eq "deleteEntry" && $opt{"other"}; |
77 |
|
} |
281 |
|
my $id = 1; |
282 |
|
$id = $row[0] + 1 if $results->numrows (); |
283 |
|
|
284 |
< |
$query = "insert into ntuple (id, dataset, creationTime, lastUpdateTime, user, format, location, fileList, nFiles, sizeInGB, status, comment, pset, crabCfg, jsonFile, lumiSummary, version) values ($id, '$dataset', now(), now(), '$user', '$format', '$fullLocation', '$fileList', $nFiles, $size, '$status', '$comment', '$pset', '$crabCfg', '$jsonFile', '$lumiSummary', '$release')"; |
284 |
> |
$query = "insert into ntuple (id, dataset, creationTime, lastUpdateTime, lastUpdateUser, user, format, location, fileList, nFiles, sizeInGB, status, comment, pset, crabCfg, jsonFile, lumiSummary, version) values ($id, '$dataset', now(), now(), '$user', '$user', '$format', '$fullLocation', '$fileList', $nFiles, $size, '$status', '$comment', '$pset', '$crabCfg', '$jsonFile', '$lumiSummary', '$release')"; |
285 |
|
} |
286 |
|
if ($id > 0) |
287 |
|
{ |
290 |
|
|
291 |
|
$values .= ", dataset='$dataset'" if $dataset; |
292 |
|
$values .= ", lastUpdateTime=now()"; |
293 |
+ |
$values .= ", lastUpdateUser='$user'"; |
294 |
|
$values .= ", format='$format'" if $format; |
295 |
|
$values .= ", location='$fullLocation'" if $location; |
296 |
|
$values .= ", fileList='$fileList'" if $fileList; |
317 |
|
{ |
318 |
|
my $id = shift; |
319 |
|
my $comment = shift; |
320 |
+ |
my $user = shift; |
321 |
|
|
322 |
|
$comment = addSlashes ($comment); |
323 |
|
|
324 |
< |
my $query = "update other set lastUpdateTime=now(), comment='$comment' where id=$id"; |
324 |
> |
my $query = "update other set lastUpdateTime=now(), lastUpdateUser='$user', comment='$comment' where id=$id"; |
325 |
|
$db->selectdb ("ntuple"); |
326 |
|
my $results = $db->query ($query); |
327 |
|
|
437 |
|
printf "%-29s%s\n", " -p, --pyConfig FILE", "default Python config for the release"; |
438 |
|
printf "%-29s%s\n", " -r, --release DIRECTORY", "CMSSW release containing ntuple packages"; |
439 |
|
} |
440 |
+ |
elsif ($command eq "downloadRelease") |
441 |
+ |
{ |
442 |
+ |
print "Usage: $exeName [OPTION]... downloadRelease NAME\n"; |
443 |
+ |
print "Copies an ntuple release to the current directory on the Tier 3. Optionally\n"; |
444 |
+ |
print "copies the corresponding Python configuration file registered in the database.\n"; |
445 |
+ |
print "\n"; |
446 |
+ |
print "Mandatory arguments to long options are mandatory for short options too.\n"; |
447 |
+ |
printf "%-29s%s\n", " -p, --pyConfig FILE", "Python configuration file name"; |
448 |
+ |
} |
449 |
|
else |
450 |
|
{ |
451 |
|
print "Usage: $exeName [OPTION]... COMMAND NAME\n"; |
457 |
|
print "\n"; |
458 |
|
print "COMMAND may be one of the following:\n"; |
459 |
|
printf "%-29s%s\n", " create", "creates the entry"; |
460 |
< |
printf "%-29s%s\n", " create", "creates an entry for non-ntuple data"; |
460 |
> |
printf "%-29s%s\n", " createOther", "creates an entry for non-ntuple data"; |
461 |
|
printf "%-29s%s\n", " update", "updates the entry"; |
462 |
|
printf "%-29s%s\n", " finish", "finalizes the database entry"; |
463 |
|
printf "%-29s%s\n", " deleteEntry", "removes the database entry"; |
464 |
|
printf "%-29s%s\n", " deprecate", "marks the dataset for deletion"; |
465 |
|
printf "%-29s%s\n", " uploadRelease", "upload an ntuple release"; |
466 |
+ |
printf "%-29s%s\n", " downloadRelease", "download an ntuple release"; |
467 |
|
} |
468 |
|
|
469 |
|
exit; |
549 |
|
} |
550 |
|
|
551 |
|
sub |
552 |
< |
datasetExists |
552 |
> |
downloadRelease |
553 |
|
{ |
554 |
< |
my $dataset = shift; |
554 |
> |
my $release = shift; |
555 |
> |
my $pyConfigName = shift; |
556 |
|
|
557 |
< |
my $query = "select id from ntuple where dataset='$dataset'"; |
557 |
> |
my $query = "select id,pset from ntupleRelease where name='$release'"; |
558 |
|
$db->selectdb ("ntuple"); |
559 |
|
my $results = $db->query ($query); |
560 |
< |
|
561 |
< |
return $results->numrows (); |
560 |
> |
if ($results->numrows () != 1) |
561 |
> |
{ |
562 |
> |
print "Ntuple release \"$release\" not found!\n"; |
563 |
> |
exit; |
564 |
> |
} |
565 |
> |
if (!(-e "/home/hart/public_html/releases/$release.tar.gz")) |
566 |
> |
{ |
567 |
> |
print "Release is in the database but no package exists!\n"; |
568 |
> |
exit; |
569 |
> |
} |
570 |
> |
if ($pyConfigName) |
571 |
> |
{ |
572 |
> |
my @row = $results->fetchrow (); |
573 |
> |
open (PY_CONFIG, ">$pyConfigName"); |
574 |
> |
print PY_CONFIG $row[1]; |
575 |
> |
close (PY_CONFIG); |
576 |
> |
} |
577 |
> |
copy ("/home/hart/public_html/releases/$release.tar.gz", "$release.tar.gz"); |
578 |
|
} |
579 |
|
|
580 |
|
sub |
614 |
|
$location = addSlashes ($location); |
615 |
|
$comment = addSlashes ($comment); |
616 |
|
|
617 |
< |
my $query = "insert into other (id, creationTime, lastUpdateTime, user, location, nFiles, sizeInGB, comment) values ($id, now(), now(), '$user', '$location', $nFiles, $size, '$comment')"; |
617 |
> |
my $query = "insert into other (id, creationTime, lastUpdateTime, lastUpdateUser, user, location, nFiles, sizeInGB, comment) values ($id, now(), now(), '$user', '$user', '$location', $nFiles, $size, '$comment')"; |
618 |
|
$db->selectdb ("ntuple"); |
619 |
|
my $results = $db->query ($query); |
620 |
|
|