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.7 by ahart, Wed Aug 1 14:35:07 2012 UTC vs.
Revision 1.16 by ahart, Sat Jan 19 06:56:01 2013 UTC

# Line 7 | Line 7 | use File::Copy;
7  
8   sub getDataset;
9   sub dbUpdate;
10 + sub dbUpdateOther;
11   sub dbDelete;
12 + sub dbDeleteOther;
13   sub addSlashes;
14   sub uploadRelease;
15 + sub downloadRelease;
16 + sub datasetExists;
17 + sub uploadConfig;
18 + sub locationExists;
19  
20   our $db = Mysql->connect ("cmshead.mps.ohio-state.edu", "ntuple", "osuT3User") or die "Failed to connect to Tier 3, stopped";
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", "fileList|t=s", "release|r=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", "fileList|t=s", "release|r=s", "other|o", "recipe|e=s", "help|h");
25   my $argc = @ARGV;
26  
27   printHelp ($ARGV[0]) if $opt{"help"};
28 < printHelp () if $argc != 2;
29 < printHelp () if $ARGV[0] ne "create" && $ARGV[0] ne "update" && $ARGV[0] ne "finish" && $ARGV[0] ne "deprecate" && $ARGV[0] ne "uploadRelease" && $ARGV[0] ne "deleteEntry";
28 > printHelp () if $argc != 2 && $ARGV[0] ne "createOther";
29 > 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";
30   if (($ARGV[0] eq "create" || $ARGV[0] eq "finish") && !$opt{"location"})
31    {
32      print "The directory containing the ntuples must be given!\n";
33      exit;
34    }
35 < if ($ARGV[0] eq "uploadRelease" && !$opt{"pyConfig"} && !$opt{"release"})
35 > if ($ARGV[0] eq "uploadRelease" && (!$opt{"pyConfig"} || !$opt{"release"} || !$opt{"recipe"}))
36    {
37 <    print "Both the Python and the CMSSW release must be given!\n";
37 >    print "The Python config, CMSSW release directory, and recipe file must be given!\n";
38      exit;
39    }
40 < if ($ARGV[0] ne "uploadRelease")
40 > if ($ARGV[0] eq "uploadConfig" && (!$opt{"pyConfig"} || !$opt{"release"}))
41    {
42 <    my $id = -1;
43 <    my $fullDataset;
38 <    ($id, $fullDataset) = getDataset ($ARGV[0], $ARGV[1]) if $ARGV[0] ne "create";
39 <    $fullDataset = $ARGV[1] if $id < 0;
40 <    $ARGV[0] = "create" if $id < 0;
41 <    my $status = "present";
42 <    $status = "" if $ARGV[0] eq "update";
43 <    $status = "deprecated" if $ARGV[0] eq "deprecate";
44 <    $opt{"format"} = "BEAN" if $ARGV[0] eq "create" && !$opt{"format"};
45 <    dbUpdate ($id, $fullDataset, $ENV{"USER"}, $opt{"format"}, $opt{"location"}, $opt{"fileList"}, $status, $opt{"comment"}, $opt{"pyConfig"}, $opt{"crabCfg"}, $opt{"jsonFile"}, $opt{"lumiSummary"}, $opt{"release"});
46 <    dbDelete ($id) if $ARGV[0] eq "deleteEntry";
42 >    print "The Python config and ntuple release must be given!\n";
43 >    exit;
44    }
45 < else
45 > if ($opt{"location"} && locationExists ($opt{"location"}))
46 >  {
47 >    print "This location is already registered in the database!\n";
48 >    exit;
49 >  }
50 > if ($ARGV[0] eq "uploadRelease")
51    {
52      my $parentDir = "./$opt{'release'}";
53      $parentDir =~ s/CMSSW_[^\/]*//g;
# Line 54 | Line 56 | else
56      $cmsswRelease =~ s/^.*CMSSW_([^\/]*).*$/CMSSW_$1/;
57      `tar -C $parentDir -czf $ARGV[1].tar.gz $opt{"release"}`;
58      $opt{"format"} = "BEAN" if !$opt{"format"};
59 <    uploadRelease ($opt{"format"}, $cmsswRelease, "$ARGV[1].tar.gz", $opt{"pyConfig"}, $ARGV[1], $ENV{"USER"}, $opt{"comment"});
59 >    uploadRelease ($opt{"format"}, $cmsswRelease, "$ARGV[1].tar.gz", $opt{"pyConfig"}, $ARGV[1], "$ENV{'USER'}", $opt{"comment"}, $opt{"recipe"});
60 >  }
61 > elsif ($ARGV[0] eq "downloadRelease")
62 >  {
63 >    downloadRelease ($ARGV[1], $opt{"pyConfig"});
64 >  }
65 > elsif ($ARGV[0] eq "uploadConfig")
66 >  {
67 >    uploadConfig ($ARGV[1], $ENV{"USER"}, $opt{"pyConfig"}, $opt{"release"}, $opt{"comment"});
68 >  }
69 > elsif ($ARGV[0] eq "createOther")
70 >  {
71 >    my @listOfFiles = @ARGV;
72 >    @listOfFiles = reverse (@listOfFiles);
73 >    pop (@listOfFiles);
74 >    @listOfFiles = reverse (@listOfFiles);
75 >    dbOtherCreate ("$ENV{'USER'}\@$ENV{'HOSTNAME'}", \@listOfFiles, $opt{"comment"});
76 >  }
77 > else
78 >  {
79 >    my $id = -1;
80 >    my $fullDataset;
81 >    ($id, $fullDataset) = getDataset ($ARGV[0], $ARGV[1]) if $ARGV[0] ne "create" && ($ARGV[0] ne "update" || !$opt{"other"}) && ($ARGV[0] ne "deleteEntry" || !$opt{"other"});
82 >    $id = $ARGV[1] if ($ARGV[0] eq "update" && $opt{"other"}) || ($ARGV[0] eq "deleteEntry" && $opt{"other"});
83 >    $fullDataset = $ARGV[1] if $id < 0;
84 >    $ARGV[0] = "create" if $id < 0;
85 >    my $status = "present";
86 >    $status = "" if $ARGV[0] eq "update";
87 >    $status = "deprecated" if $ARGV[0] eq "deprecate";
88 >    $opt{"format"} = "BEAN" if $ARGV[0] eq "create" && !$opt{"format"};
89 >    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"};
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"};
93    }
94  
95   sub
# Line 80 | Line 115 | getDataset
115    my $queryDataset = $dataset;
116    $queryDataset =~ s/\*/%/g;
117    $queryDataset =~ s/(.*)/%$1%/g;
118 <  my $query = "select id,dataset,user,creationTime from ntuple where dataset like '$queryDataset' order by lastUpdateTime";
118 >  my $query = "select id,dataset,user,creationTime from ntuple where dataset like '$queryDataset' order by creationTime";
119    $db->selectdb ("ntuple");
120    $results = $db->query ($query);
121    if ($results->numrows () == 1)
# Line 144 | Line 179 | dbUpdate
179   {
180    my $id = shift;
181    my $dataset = shift;
182 <  my $user = shift;
182 >  my $userAndHost = shift;
183    my $format = shift;
184    my $location = shift;
185    my $fileListName = shift;
# Line 156 | Line 191 | dbUpdate
191    my $lumiSummaryName = shift;
192    my $release = shift;
193  
194 +  my $user = $userAndHost;
195 +  $user =~ s/@.*$//g;
196 +
197    my $fileList;
198    my $pset;
199    my $crabCfg;
# Line 255 | Line 293 | dbUpdate
293    my $query;
294    if ($id < 0)
295      {
296 +      $query = "select id from ntuple where dataset='$dataset'";
297 +      $db->selectdb ("ntuple");
298 +      $results = $db->query ($query);
299 +      if ($results->numrows ())
300 +        {
301 +          print "This dataset already exists in the database. Create anyway? (y/N): ";
302 +          my $response = <STDIN>;
303 +          $response =~ s/\n//g;
304 +          $response = "n" if !$response;
305 +          exit if substr (lc ($response), 0, 1) ne 'y';
306 +        }
307 +
308        $query = "select max(id) from ntuple";
309        $db->selectdb ("ntuple");
310        $results = $db->query ($query);
# Line 262 | Line 312 | dbUpdate
312        my $id = 1;
313        $id = $row[0] + 1 if $results->numrows ();
314  
315 <      $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')";
315 >      $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')";
316      }
317    if ($id > 0)
318      {
# Line 271 | Line 321 | dbUpdate
321  
322        $values .= ", dataset='$dataset'" if $dataset;
323        $values .= ", lastUpdateTime=now()";
324 +      $values .= ", lastUpdateUser='$user'";
325        $values .= ", format='$format'" if $format;
326        $values .= ", location='$fullLocation'" if $location;
327        $values .= ", fileList='$fileList'" if $fileList;
# Line 293 | Line 344 | dbUpdate
344   }
345  
346   sub
347 + dbUpdateOther
348 + {
349 +  my $id = shift;
350 +  my $comment = shift;
351 +  my $user = shift;
352 +
353 +  $comment = addSlashes ($comment);
354 +
355 +  my $query = "update other set lastUpdateTime=now(), lastUpdateUser='$user', comment='$comment'  where id=$id";
356 +  $db->selectdb ("ntuple");
357 +  my $results = $db->query ($query);
358 +
359 +  return $results;
360 + }
361 +
362 + sub
363   dbDelete
364   {
365    my $id = shift;
366  
300  return if $id < 0;
367    my $query = "delete from ntuple where id=$id";
368    $db->selectdb ("ntuple");
369    my $results = $db->query ($query);
370   }
371  
372   sub
373 + dbDeleteOther
374 + {
375 +  my $id = shift;
376 +
377 +  my $query = "delete from other where id=$id";
378 +  $db->selectdb ("ntuple");
379 +  my $results = $db->query ($query);
380 + }
381 +
382 + sub
383   printHelp
384   {
385    my $command = shift;
# Line 327 | Line 403 | printHelp
403        printf "%-29s%s\n", "  -r, --release NAME", "ntuple release used to produce ntuples";
404        printf "%-29s%s\n", "  -s, --lumiSummary FILE", "lumiSummary.json reported by CRAB";
405      }
406 +  elsif ($command eq "createOther")
407 +    {
408 +      print "Usage: $exeName [OPTION]... createOther DIRECTORIES_AND_FILES\n";
409 +      print "Creates an entry in the database for non-ntuple data.\n";
410 +      print "\n";
411 +      print "Mandatory arguments to long options are mandatory for short options too.\n";
412 +      printf "%-29s%s\n", "  -c, --comment COMMENT", "comment for the database entry";
413 +    }
414    elsif ($command eq "update")
415      {
416        print "Usage: $exeName [OPTION]... update NAME\n";
# Line 338 | Line 422 | printHelp
422        printf "%-29s%s\n", "  -f, --format FORMAT", "ntuple format";
423        printf "%-29s%s\n", "  -j, --jsonFile FILE", "JSON file used for this dataset";
424        printf "%-29s%s\n", "  -l, --location DIRECTORY", "directory containing the ntuples";
425 +      printf "%-29s%s\n", "  -o, --other", "update an entry in the non-ntuple database";
426        printf "%-29s%s\n", "  -p, --pyConfig FILE", "Python config used to produce ntuples";
427        printf "%-29s%s\n", "  -r, --release NAME", "ntuple release used to produce ntuples";
428        printf "%-29s%s\n", "  -s, --lumiSummary FILE", "lumiSummary.json reported by CRAB";
# Line 345 | Line 430 | printHelp
430    elsif ($command eq "finish")
431      {
432        print "Usage: $exeName -l DIRECTORY finish NAME\n";
348
433        print "Finalizes the database entry for dataset NAME, changing its status to\n";
434        print "\"present\".  This is intended to be the final step in command-line based ntuple\n";
435        print "production.\n";
# Line 355 | Line 439 | printHelp
439      }
440    elsif ($command eq "deleteEntry")
441      {
442 <      print "Usage: $exeName deleteEntry NAME\n";
442 >      print "Usage: $exeName [OPTION]... deleteEntry NAME\n";
443        print "Deletes the database entry for dataset NAME. This is intended primarily for\n";
444        print "mistaken database entries. If you wish to actually delete a set of ntuples,\n";
445        print "please use the \"deprecate\" command instead.\n";
446 +      print "\n";
447 +      printf "%-29s%s\n", "  -o, --other", "update an entry in the non-ntuple database";
448      }
449    elsif ($command eq "deprecate")
450      {
# Line 369 | Line 455 | printHelp
455      }
456    elsif ($command eq "uploadRelease")
457      {
458 <      print "Usage: $exeName -p FILE -r DIRECTORY [OPTION]... uploadRelease NAME\n";
458 >      print "Usage: $exeName -e FILE -p FILE -r DIRECTORY [OPTION]... uploadRelease NAME\n";
459        print "Copies an ntuple release to the appropriate area on the Tier 3, and creates a\n";
460        print "database entry for it, with NAME being the name of the release. An ntuple\n";
461        print "release is a CMSSW release with all the necessary packages added for creating\n";
# Line 377 | Line 463 | printHelp
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", "  -e, --recipe FILE", "file containing the recipe for the release";
467        printf "%-29s%s\n", "  -f, --format FORMAT", "ntuple format (default: BEAN)";
468        printf "%-29s%s\n", "  -p, --pyConfig FILE", "default Python config for the release";
469        printf "%-29s%s\n", "  -r, --release DIRECTORY", "CMSSW release containing ntuple packages";
470      }
471 +  elsif ($command eq "downloadRelease")
472 +    {
473 +      print "Usage: $exeName [OPTION]... downloadRelease NAME\n";
474 +      print "Copies an ntuple release to the current directory on the Tier 3. Optionally\n";
475 +      print "copies the corresponding Python configuration file registered in the database.\n";
476 +      print "\n";
477 +      print "Mandatory arguments to long options are mandatory for short options too.\n";
478 +      printf "%-29s%s\n", "  -p, --pyConfig FILE", "Python configuration file name";
479 +    }
480 +  elsif ($command eq "uploadConfig")
481 +    {
482 +      print "Usage: $exeName -p FILE -r DIRECTORY [OPTION]... uploadConfig NAME\n";
483 +      print "Creates an entry in the database for a customized Python configuration file.\n";
484 +      print "\n";
485 +      print "Mandatory arguments to long options are mandatory for short options too.\n";
486 +      printf "%-29s%s\n", "  -c, --comment COMMENT", "comment for the database entry";
487 +      printf "%-29s%s\n", "  -p, --pyConfig FILE", "Python config file";
488 +      printf "%-29s%s\n", "  -r, --release NAME", "ntuple release with which to use this config";
489 +    }
490    else
491      {
492        print "Usage: $exeName [OPTION]... COMMAND NAME\n";
# Line 392 | Line 498 | printHelp
498        print "\n";
499        print "COMMAND may be one of the following:\n";
500        printf "%-29s%s\n", "  create", "creates the entry";
501 +      printf "%-29s%s\n", "  createOther", "creates an entry for non-ntuple data";
502        printf "%-29s%s\n", "  update", "updates the entry";
503        printf "%-29s%s\n", "  finish", "finalizes the database entry";
504        printf "%-29s%s\n", "  deleteEntry", "removes the database entry";
505        printf "%-29s%s\n", "  deprecate", "marks the dataset for deletion";
506        printf "%-29s%s\n", "  uploadRelease", "upload an ntuple release";
507 +      printf "%-29s%s\n", "  downloadRelease", "download an ntuple release";
508 +      printf "%-29s%s\n", "  uploadConfig", "upload an ntuple config";
509      }
510  
511    exit;
# Line 450 | Line 559 | uploadRelease
559    my $name = shift;
560    my $user = shift;
561    my $comment = shift;
562 +  my $recipeName = shift;
563  
454  move ($release, "/home/hart/public_html/releases/$name.tar.gz") or die "Ntuple releases may only be uploaded on the Tier 3, stopped";
564    if (!(-e $psetName))
565      {
566        print "$psetName does not exist!\n";
567        exit;
568      }
569 +  if (!(-e $recipeName))
570 +    {
571 +      print "$recipeName does not exist!\n";
572 +      exit;
573 +    }
574 +  move ($release, "/home/hart/public_html/releases/$name.tar.gz") or die "Ntuple releases may only be uploaded on the Tier 3, stopped";
575    open (PY_CONFIG, "<$psetName");
576    my @pset = <PY_CONFIG>;
577    close (PY_CONFIG);
578    my $pset = join ("", @pset);
579 +  open (RECIPE, "<$recipeName");
580 +  my @recipe = <RECIPE>;
581 +  close (RECIPE);
582 +  my $recipe = join ("\n", @recipe);
583  
584    my $query = "select max(id) from ntupleRelease";
585    $db->selectdb ("ntuple");
# Line 475 | Line 594 | uploadRelease
594    $format = addSlashes ($format);
595    $cmsswRelease = addSlashes ($cmsswRelease);
596    $comment = addSlashes ($comment);
597 +  $recipe = addSlashes ($recipe);
598 +
599 +  my $query = "insert into ntupleRelease (id, name, pset, user, pending, format, cmsswRelease, comment, recipe) values ($id, '$name', '$pset', '$user', 1, '$format', '$cmsswRelease', '$comment', '$recipe')";
600 +  $db->selectdb ("ntuple");
601 +  my $results = $db->query ($query);
602 + }
603 +
604 + sub
605 + downloadRelease
606 + {
607 +  my $release = shift;
608 +  my $pyConfigName = shift;
609 +
610 +  my $query = "select id,pset from ntupleRelease where name='$release'";
611 +  $db->selectdb ("ntuple");
612 +  my $results = $db->query ($query);
613 +  if ($results->numrows () != 1)
614 +    {
615 +      print "Ntuple release \"$release\" not found!\n";
616 +      exit;
617 +    }
618 +  if (!(-e "/home/hart/public_html/releases/$release.tar.gz"))
619 +    {
620 +      print "Release is in the database but no package exists!\n";
621 +      exit;
622 +    }
623 +  if ($pyConfigName)
624 +    {
625 +      my @row = $results->fetchrow ();
626 +      open (PY_CONFIG, ">$pyConfigName");
627 +      print PY_CONFIG $row[1];
628 +      close (PY_CONFIG);
629 +    }
630 +  copy ("/home/hart/public_html/releases/$release.tar.gz", "$release.tar.gz");
631 + }
632 +
633 + sub
634 + dbOtherCreate
635 + {
636 +  my $userAndHost = shift;
637 +  my $listOfFiles = shift;
638 +  my $comment = shift;
639 +
640 +  my $user = $userAndHost;
641 +  $user =~ s/@.*$//g;
642 +
643 +  my $size = 0.0;
644 +  my $nFiles = 0.0;
645 +  for (my $i = 0; $i < @$listOfFiles; $i++)
646 +    {
647 +      if (!(-e $$listOfFiles[$i]))
648 +        {
649 +          print "$$listOfFiles[$i] does not exist!\n";
650 +          exit;
651 +        }
652 +      $nFiles += `ls -R $$listOfFiles[$i] | grep -v ':\$' | grep -v '^\$' | wc -l`;
653 +      my $fileSize = `du -s $$listOfFiles[$i]`;
654 +      $fileSize =~ s/([^ ]*) .*/$1/;
655 +      $fileSize /= 1024 * 1024;
656 +      $size += $fileSize;
657 +      $$listOfFiles[$i] = "$ENV{'PWD'}/$$listOfFiles[$i]" if !($$listOfFiles[$i] =~ m/^\//);
658 +    }
659 +  $size = sprintf "%.2f", $size;
660 +  my $location = join ("<br />", @$listOfFiles);
661 +
662 +  my $query = "select max(id) from other";
663 +  $db->selectdb ("ntuple");
664 +  my $results = $db->query ($query);
665 +  my @row = $results->fetchrow ();
666 +  my $id = 1;
667 +  $id = $row[0] + 1 if $results->numrows ();
668 +
669 +  $user = addSlashes ($user);
670 +  $location = addSlashes ($location);
671 +  $comment = addSlashes ($comment);
672  
673 <  my $query = "insert into ntupleRelease (id, name, pset, user, pending, format, cmsswRelease, comment) values ($id, '$name', '$pset', '$user', 1, '$format', '$cmsswRelease', '$comment')";
673 >  $query = "insert into other (id, creationTime, lastUpdateTime, lastUpdateUser, user, location, nFiles, sizeInGB, comment) values ($id, now(), now(), '$userAndHost', '$user', '$location', $nFiles, $size, '$comment')";
674 >  $db->selectdb ("ntuple");
675 >  $results = $db->query ($query);
676 >
677 >  print "ID $id\n";
678 > }
679 >
680 > sub
681 > uploadConfig
682 > {
683 >  my $name = shift;
684 >  my $user = shift;
685 >  my $psetName = shift;
686 >  my $release = shift;
687 >  my $comment = shift;
688 >
689 >  if (!(-e $psetName))
690 >    {
691 >      print "$psetName does not exist!\n";
692 >      exit;
693 >    }
694 >  if ($release)
695 >    {
696 >      my $query = "select id from ntupleRelease where name='$release'";
697 >      $db->selectdb ("ntuple");
698 >      my $results = $db->query ($query);
699 >      if ($results->numrows () != 1)
700 >        {
701 >          print "Ntuple release \"$release\" not found!\n";
702 >          exit;
703 >        }
704 >    }
705 >  open (PSET, "<$psetName");
706 >  my @pset = <PSET>;
707 >  close (PSET);
708 >  my $pset = join ("", @pset);
709 >
710 >  my $query = "select max(id) from ntupleConfig";
711 >  $db->selectdb ("ntuple");
712 >  my $results = $db->query ($query);
713 >  my @row = $results->fetchrow ();
714 >  my $id = 1;
715 >  $id = $row[0] + 1 if $results->numrows ();
716 >
717 >  $name = addSlashes ($name);
718 >  $user = addSlashes ($user);
719 >  $pset = addSlashes ($pset);
720 >  $release = addSlashes ($release);
721 >  $comment = addSlashes ($comment);
722 >
723 >  my $query = "insert into ntupleConfig (id, name, pset, user, pending, ntupleRelease, comment) values ($id, '$name', '$pset', '$user', 1, '$release', '$comment')";
724 >  $db->selectdb ("ntuple");
725 >  $results = $db->query ($query);
726 > }
727 >
728 > sub
729 > locationExists
730 > {
731 >  my $location = shift;
732 >
733 >  $location =~ s/^(.*)\/+$/$1/;
734 >  my $query = "select id from ntuple where location like '$location%'";
735    $db->selectdb ("ntuple");
736    my $results = $db->query ($query);
737 +  return 1 if $results->numrows ();
738 +
739 +  if ($location =~ m/^\/store\/.*$/)
740 +    {
741 +      $location =~ s/^\/store\/(.*)$/\/data\/se\/store\/$1/;
742 +    }
743 +  elsif ($location =~ m/^\/data\/se\/store\/.*$/)
744 +    {
745 +      $location =~ s/^\/data\/se\/store\/(.*)$/\/store\/$1/;
746 +    }
747 +
748 +  my $query = "select id from ntuple where location like '$location%'";
749 +  $db->selectdb ("ntuple");
750 +  my $results = $db->query ($query);
751 +  return 1 if $results->numrows ();
752 +
753 +  return 0;
754   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines