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.13 by ahart, Mon Oct 22 13:50:25 2012 UTC vs.
Revision 1.14 by ahart, Mon Oct 22 14:45:07 2012 UTC

# Line 14 | Line 14 | sub addSlashes;
14   sub uploadRelease;
15   sub downloadRelease;
16   sub datasetExists;
17 + sub uploadConfig;
18  
19   our $db = Mysql->connect ("cmshead.mps.ohio-state.edu", "ntuple", "osuT3User") or die "Failed to connect to Tier 3, stopped";
20  
# Line 24 | Line 25 | my $argc = @ARGV;
25  
26   printHelp ($ARGV[0]) if $opt{"help"};
27   printHelp () if $argc != 2 && $ARGV[0] ne "createOther";
28 < 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 > 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" && $ARGV[0] ne "uploadConfig";
29   if (($ARGV[0] eq "create" || $ARGV[0] eq "finish") && !$opt{"location"})
30    {
31      print "The directory containing the ntuples must be given!\n";
# Line 35 | Line 36 | if ($ARGV[0] eq "uploadRelease" && (!$op
36      print "The Python config, CMSSW release directory, and recipe file must be given!\n";
37      exit;
38    }
39 + if ($ARGV[0] eq "uploadConfig" && (!$opt{"pyConfig"} || !$opt{"release"}))
40 +  {
41 +    print "The Python config and ntuple release must be given!\n";
42 +    exit;
43 +  }
44   if ($ARGV[0] eq "uploadRelease")
45    {
46      my $parentDir = "./$opt{'release'}";
# Line 50 | Line 56 | elsif ($ARGV[0] eq "downloadRelease")
56    {
57      downloadRelease ($ARGV[1], $opt{"pyConfig"});
58    }
59 + elsif ($ARGV[0] eq "uploadConfig")
60 +  {
61 +    uploadConfig ($ARGV[1], $ENV{"USER"}, $opt{"pyConfig"}, $opt{"release"}, $opt{"comment"});
62 +  }
63   elsif ($ARGV[0] eq "createOther")
64    {
65      my @listOfFiles = @ARGV;
# Line 399 | Line 409 | printHelp
409    elsif ($command eq "finish")
410      {
411        print "Usage: $exeName -l DIRECTORY finish NAME\n";
402
412        print "Finalizes the database entry for dataset NAME, changing its status to\n";
413        print "\"present\".  This is intended to be the final step in command-line based ntuple\n";
414        print "production.\n";
# Line 447 | Line 456 | printHelp
456        print "Mandatory arguments to long options are mandatory for short options too.\n";
457        printf "%-29s%s\n", "  -p, --pyConfig FILE", "Python configuration file name";
458      }
459 +  elsif ($command eq "uploadConfig")
460 +    {
461 +      print "Usage: $exeName -p FILE -r DIRECTORY [OPTION]... uploadConfig NAME\n";
462 +      print "Creates an entry in the database for a customized Python configuration file.\n";
463 +      print "\n";
464 +      print "Mandatory arguments to long options are mandatory for short options too.\n";
465 +      printf "%-29s%s\n", "  -c, --comment COMMENT", "comment for the database entry";
466 +      printf "%-29s%s\n", "  -p, --pyConfig FILE", "Python config file";
467 +      printf "%-29s%s\n", "  -r, --release NAME", "ntuple release with which to use this config";
468 +    }
469    else
470      {
471        print "Usage: $exeName [OPTION]... COMMAND NAME\n";
# Line 465 | Line 484 | printHelp
484        printf "%-29s%s\n", "  deprecate", "marks the dataset for deletion";
485        printf "%-29s%s\n", "  uploadRelease", "upload an ntuple release";
486        printf "%-29s%s\n", "  downloadRelease", "download an ntuple release";
487 +      printf "%-29s%s\n", "  uploadConfig", "upload an ntuple config";
488      }
489  
490    exit;
# Line 626 | Line 646 | dbOtherCreate
646    $location = addSlashes ($location);
647    $comment = addSlashes ($comment);
648  
649 <  my $query = "insert into other (id, creationTime, lastUpdateTime, lastUpdateUser, user, location, nFiles, sizeInGB, comment) values ($id, now(), now(), '$user', '$user', '$location', $nFiles, $size, '$comment')";
649 >  $query = "insert into other (id, creationTime, lastUpdateTime, lastUpdateUser, user, location, nFiles, sizeInGB, comment) values ($id, now(), now(), '$user', '$user', '$location', $nFiles, $size, '$comment')";
650    $db->selectdb ("ntuple");
651 <  my $results = $db->query ($query);
651 >  $results = $db->query ($query);
652  
653    print "ID $id\n";
654   }
655 +
656 + sub
657 + uploadConfig
658 + {
659 +  my $name = shift;
660 +  my $user = shift;
661 +  my $psetName = shift;
662 +  my $release = shift;
663 +  my $comment = shift;
664 +
665 +  if (!(-e $psetName))
666 +    {
667 +      print "$psetName does not exist!\n";
668 +      exit;
669 +    }
670 +  if ($release)
671 +    {
672 +      my $query = "select id from ntupleRelease where name='$release'";
673 +      $db->selectdb ("ntuple");
674 +      my $results = $db->query ($query);
675 +      if ($results->numrows () != 1)
676 +        {
677 +          print "Ntuple release \"$release\" not found!\n";
678 +          exit;
679 +        }
680 +    }
681 +  open (PSET, "<$psetName");
682 +  my @pset = <PSET>;
683 +  close (PSET);
684 +  my $pset = join ("", @pset);
685 +
686 +  my $query = "select max(id) from ntupleConfig";
687 +  $db->selectdb ("ntuple");
688 +  my $results = $db->query ($query);
689 +  my @row = $results->fetchrow ();
690 +  my $id = 1;
691 +  $id = $row[0] + 1 if $results->numrows ();
692 +
693 +  $name = addSlashes ($name);
694 +  $user = addSlashes ($user);
695 +  $pset = addSlashes ($pset);
696 +  $release = addSlashes ($release);
697 +  $comment = addSlashes ($comment);
698 +
699 +  my $query = "insert into ntupleConfig (id, name, pset, user, pending, ntupleRelease, comment) values ($id, '$name', '$pset', '$user', 1, '$release', '$comment')";
700 +  $db->selectdb ("ntuple");
701 +  $results = $db->query ($query);
702 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines