ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/DBTools/scripts/osudb
(Generate patch)

Comparing UserCode/OSUT3Analysis/DBTools/scripts/osudb (file contents):
Revision 1.10 by ahart, Wed Oct 17 18:28:47 2012 UTC vs.
Revision 1.12 by ahart, Mon Oct 22 12:50:07 2012 UTC

# Line 12 | Line 12 | sub dbDelete;
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";
# Line 23 | Line 24 | my $argc = @ARGV;
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";
# Line 43 | Line 44 | if ($ARGV[0] eq "uploadRelease")
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'}\@$ENV{'HOSTNAME'}", $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    {
# Line 51 | Line 56 | elsif ($ARGV[0] eq "createOther")
56      @listOfFiles = reverse (@listOfFiles);
57      pop (@listOfFiles);
58      @listOfFiles = reverse (@listOfFiles);
59 <    dbOtherCreate ("$ENV{'USER'}\@$ENV{'HOSTNAME'}", \@listOfFiles, $opt{"comment"});
59 >    dbOtherCreate ("$ENV{'USER'}", \@listOfFiles, $opt{"comment"});
60    }
61   else
62    {
# Line 432 | Line 437 | printHelp
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";
# Line 443 | Line 457 | printHelp
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;
# Line 534 | Line 549 | uploadRelease
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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines