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 |
> |
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'}\@$ENV{'HOSTNAME'}", $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'}\@$ENV{'HOSTNAME'}", \@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"}, $ENV{"USER"}) 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 |
|
} |
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 |
+ |
downloadRelease |
553 |
+ |
{ |
554 |
+ |
my $release = shift; |
555 |
+ |
my $pyConfigName = shift; |
556 |
+ |
|
557 |
+ |
my $query = "select id,pset from ntupleRelease where name='$release'"; |
558 |
+ |
$db->selectdb ("ntuple"); |
559 |
+ |
my $results = $db->query ($query); |
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 |
581 |
|
dbOtherCreate |
582 |
|
{ |
583 |
|
my $user = shift; |