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.17 by ahart, Sat Jan 19 07:16:03 2013 UTC vs.
Revision 1.21 by ahart, Sun Feb 3 00:14:20 2013 UTC

# Line 21 | Line 21 | our $db = Mysql->connect ("cmshead.mps.o
21  
22   my %opt;
23   Getopt::Long::Configure ("bundling");
24 < 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", "help|h");
24 > 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", "help|h");
25   my $argc = @ARGV;
26  
27   printHelp ($ARGV[0]) if $opt{"help"};
# Line 42 | Line 42 | if ($ARGV[0] eq "uploadConfig" && (!$opt
42      print "The Python config and ntuple release must be given!\n";
43      exit;
44    }
45 if ($opt{"location"} && locationExists ($opt{"location"}))
46  {
47    print "This location is already registered in the database!\n";
48    exit;
49  }
45   if ($ARGV[0] eq "uploadRelease")
46    {
47      my $parentDir = "./$opt{'release'}";
# Line 86 | Line 81 | else
81      $status = "" if $ARGV[0] eq "update";
82      $status = "deprecated" if $ARGV[0] eq "deprecate";
83      $opt{"format"} = "BEAN" if $ARGV[0] eq "create" && !$opt{"format"};
84 <    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"}) if !$opt{"other"};
84 >    if ($opt{"location"} && locationExists ($id, $opt{"location"}))
85 >      {
86 >        print "This location is already registered in the database!\n";
87 >        exit;
88 >      }
89 >    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"}) if !$opt{"other"};
90      dbUpdateOther ($id, $opt{"comment"}, "$ENV{'USER'}\@$ENV{'HOSTNAME'}") if $opt{"other"};
91      dbDelete ($id) if $ARGV[0] eq "deleteEntry" && !$opt{"other"};
92      dbDeleteOther ($id) if $ARGV[0] eq "deleteEntry" && $opt{"other"};
# Line 191 | Line 191 | dbUpdate
191    my $jsonFileName = shift;
192    my $lumiSummaryName = shift;
193    my $release = shift;
194 +  my $globalTag = shift;
195  
196    my $user = $userAndHost;
197    $user =~ s/@.*$//g;
# Line 290 | Line 291 | dbUpdate
291    $status = addSlashes ($status);
292    $comment = addSlashes ($comment);
293    $release = addSlashes ($release);
294 +  $globalTag = addSlashes ($globalTag);
295  
296    my $results;
297    my $query;
# Line 314 | Line 316 | dbUpdate
316        my $id = 1;
317        $id = $row[0] + 1 if $results->numrows ();
318  
319 <      $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(), '$userAndHost', '$user', '$format', '$fullLocation', '$fileList', $nFiles, $size, '$status', '$comment', '$pset', '$crabCfg', '$jsonFile', '$lumiSummary', '$release')";
319 >      $query = "insert into ntuple (id, dataset, creationTime, lastUpdateTime, lastUpdateUser, user, format, location, fileList, nFiles, sizeInGB, status, comment, pset, crabCfg, jsonFile, lumiSummary, version, globalTag) values ($id, '$dataset', now(), now(), '$userAndHost', '$user', '$format', '$fullLocation', '$fileList', $nFiles, $size, '$status', '$comment', '$pset', '$crabCfg', '$jsonFile', '$lumiSummary', '$release', '$globalTag')";
320      }
321    if ($id > 0)
322      {
# Line 351 | Line 353 | dbUpdate
353        $values .= ", jsonFile='$jsonFile'" if $jsonFile;
354        $values .= ", lumiSummary='$lumiSummary'" if $lumiSummary;
355        $values .= ", version='$release'" if $release;
356 +      $values .= ", globalTag='$globalTag'" if $globalTag;
357  
358        $values =~ s/^, //;
359        $query = "update ntuple set $values where id=$id";
# Line 414 | Line 417 | printHelp
417        printf "%-29s%s\n", "  -b, --crabCfg FILE", "CRAB config used to submit ntuple jobs";
418        printf "%-29s%s\n", "  -c, --comment COMMENT", "comment for the database entry";
419        printf "%-29s%s\n", "  -f, --format FORMAT", "ntuple format (default: BEAN)";
420 +      printf "%-29s%s\n", "  -g, --globalTag TAG", "global tag";
421        printf "%-29s%s\n", "  -j, --jsonFile FILE", "JSON file used for this dataset";
422        printf "%-29s%s\n", "  -l, --location DIRECTORY", "directory containing the ntuples";
423        printf "%-29s%s\n", "  -p, --pyConfig FILE", "Python config used to produce ntuples";
# Line 437 | Line 441 | printHelp
441        printf "%-29s%s\n", "  -b, --crabCfg FILE", "CRAB config used to submit ntuple jobs";
442        printf "%-29s%s\n", "  -c, --comment COMMENT", "comment for the database entry";
443        printf "%-29s%s\n", "  -f, --format FORMAT", "ntuple format";
444 +      printf "%-29s%s\n", "  -g, --globalTag TAG", "global tag";
445        printf "%-29s%s\n", "  -j, --jsonFile FILE", "JSON file used for this dataset";
446        printf "%-29s%s\n", "  -l, --location DIRECTORY", "directory containing the ntuples";
447        printf "%-29s%s\n", "  -n, --name NAME", "rename the entry";
# Line 497 | Line 502 | printHelp
502      }
503    elsif ($command eq "uploadConfig")
504      {
505 <      print "Usage: $exeName -p FILE -r DIRECTORY [OPTION]... uploadConfig NAME\n";
505 >      print "Usage: $exeName -p FILE -r RELEASE [OPTION]... uploadConfig NAME\n";
506        print "Creates an entry in the database for a customized Python configuration file.\n";
507        print "\n";
508        print "Mandatory arguments to long options are mandatory for short options too.\n";
# Line 589 | Line 594 | uploadRelease
594        print "$recipeName does not exist!\n";
595        exit;
596      }
597 <  move ($release, "/home/hart/public_html/releases/$name.tar.gz") or die "Ntuple releases may only be uploaded on the Tier 3, stopped";
597 >  move ($release, "/home/osucms/public_html/releases/$name.tar.gz") or die "Ntuple releases may only be uploaded on the Tier 3, stopped";
598    open (PY_CONFIG, "<$psetName");
599    my @pset = <PY_CONFIG>;
600    close (PY_CONFIG);
# Line 633 | Line 638 | downloadRelease
638        print "Ntuple release \"$release\" not found!\n";
639        exit;
640      }
636  if (!(-e "/home/hart/public_html/releases/$release.tar.gz"))
637    {
638      print "Release is in the database but no package exists!\n";
639      exit;
640    }
641    if ($pyConfigName)
642      {
643        my @row = $results->fetchrow ();
# Line 645 | Line 645 | downloadRelease
645        print PY_CONFIG $row[1];
646        close (PY_CONFIG);
647      }
648 <  copy ("/home/hart/public_html/releases/$release.tar.gz", "$release.tar.gz");
648 >  `wget "http://cmshead.mps.ohio-state.edu/~osucms/releases/$release.tar.gz"`;
649   }
650  
651   sub
# Line 746 | Line 746 | uploadConfig
746   sub
747   locationExists
748   {
749 +  my $id = shift;
750    my $location = shift;
751  
752    $location =~ s/^(.*)\/+$/$1/;
753 <  my $query = "select id from ntuple where location like '$location%'";
753 >  my $query = "select id from ntuple where location like '$location%' and id!=$id";
754    $db->selectdb ("ntuple");
755    my $results = $db->query ($query);
756    return 1 if $results->numrows ();
# Line 763 | Line 764 | locationExists
764        $location =~ s/^\/data\/se\/store\/(.*)$/\/store\/$1/;
765      }
766  
767 <  my $query = "select id from ntuple where location like '$location%'";
767 >  my $query = "select id from ntuple where location like '$location%' and id!=$id";
768    $db->selectdb ("ntuple");
769    my $results = $db->query ($query);
770    return 1 if $results->numrows ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines