1 |
ahart |
1.1 |
#!/usr/bin/env perl
|
2 |
|
|
|
3 |
|
|
use strict;
|
4 |
|
|
use Mysql;
|
5 |
|
|
use Getopt::Long;
|
6 |
ahart |
1.4 |
use File::Copy;
|
7 |
ahart |
1.26 |
use Term::ANSIColor;
|
8 |
ahart |
1.1 |
|
9 |
|
|
sub getDataset;
|
10 |
|
|
sub dbUpdate;
|
11 |
ahart |
1.8 |
sub dbUpdateOther;
|
12 |
ahart |
1.4 |
sub dbDelete;
|
13 |
ahart |
1.8 |
sub dbDeleteOther;
|
14 |
ahart |
1.1 |
sub addSlashes;
|
15 |
ahart |
1.4 |
sub uploadRelease;
|
16 |
ahart |
1.11 |
sub downloadRelease;
|
17 |
ahart |
1.8 |
sub datasetExists;
|
18 |
ahart |
1.14 |
sub uploadConfig;
|
19 |
ahart |
1.16 |
sub locationExists;
|
20 |
ahart |
1.25 |
sub getLocation;
|
21 |
ahart |
1.1 |
|
22 |
ahart |
1.4 |
our $db = Mysql->connect ("cmshead.mps.ohio-state.edu", "ntuple", "osuT3User") or die "Failed to connect to Tier 3, stopped";
|
23 |
ahart |
1.1 |
|
24 |
|
|
my %opt;
|
25 |
|
|
Getopt::Long::Configure ("bundling");
|
26 |
ahart |
1.25 |
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", "configName|i=s", "xSection|x=s", "higherOrderXSec|y=s", "help|h");
|
27 |
ahart |
1.1 |
my $argc = @ARGV;
|
28 |
|
|
|
29 |
ahart |
1.4 |
printHelp ($ARGV[0]) if $opt{"help"};
|
30 |
ahart |
1.8 |
printHelp () if $argc != 2 && $ARGV[0] ne "createOther";
|
31 |
ahart |
1.14 |
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";
|
32 |
ahart |
1.4 |
if (($ARGV[0] eq "create" || $ARGV[0] eq "finish") && !$opt{"location"})
|
33 |
|
|
{
|
34 |
|
|
print "The directory containing the ntuples must be given!\n";
|
35 |
|
|
exit;
|
36 |
|
|
}
|
37 |
ahart |
1.13 |
if ($ARGV[0] eq "uploadRelease" && (!$opt{"pyConfig"} || !$opt{"release"} || !$opt{"recipe"}))
|
38 |
ahart |
1.4 |
{
|
39 |
ahart |
1.13 |
print "The Python config, CMSSW release directory, and recipe file must be given!\n";
|
40 |
ahart |
1.4 |
exit;
|
41 |
|
|
}
|
42 |
ahart |
1.14 |
if ($ARGV[0] eq "uploadConfig" && (!$opt{"pyConfig"} || !$opt{"release"}))
|
43 |
|
|
{
|
44 |
|
|
print "The Python config and ntuple release must be given!\n";
|
45 |
|
|
exit;
|
46 |
|
|
}
|
47 |
ahart |
1.8 |
if ($ARGV[0] eq "uploadRelease")
|
48 |
|
|
{
|
49 |
|
|
my $parentDir = "./$opt{'release'}";
|
50 |
|
|
$parentDir =~ s/CMSSW_[^\/]*//g;
|
51 |
|
|
$parentDir =~ s/\/\/*/\//g;
|
52 |
|
|
my $cmsswRelease = $opt{'release'};
|
53 |
|
|
$cmsswRelease =~ s/^.*CMSSW_([^\/]*).*$/CMSSW_$1/;
|
54 |
|
|
`tar -C $parentDir -czf $ARGV[1].tar.gz $opt{"release"}`;
|
55 |
|
|
$opt{"format"} = "BEAN" if !$opt{"format"};
|
56 |
ahart |
1.13 |
uploadRelease ($opt{"format"}, $cmsswRelease, "$ARGV[1].tar.gz", $opt{"pyConfig"}, $ARGV[1], "$ENV{'USER'}", $opt{"comment"}, $opt{"recipe"});
|
57 |
ahart |
1.8 |
}
|
58 |
ahart |
1.11 |
elsif ($ARGV[0] eq "downloadRelease")
|
59 |
|
|
{
|
60 |
|
|
downloadRelease ($ARGV[1], $opt{"pyConfig"});
|
61 |
|
|
}
|
62 |
ahart |
1.14 |
elsif ($ARGV[0] eq "uploadConfig")
|
63 |
|
|
{
|
64 |
|
|
uploadConfig ($ARGV[1], $ENV{"USER"}, $opt{"pyConfig"}, $opt{"release"}, $opt{"comment"});
|
65 |
|
|
}
|
66 |
ahart |
1.8 |
elsif ($ARGV[0] eq "createOther")
|
67 |
|
|
{
|
68 |
|
|
my @listOfFiles = @ARGV;
|
69 |
|
|
@listOfFiles = reverse (@listOfFiles);
|
70 |
|
|
pop (@listOfFiles);
|
71 |
|
|
@listOfFiles = reverse (@listOfFiles);
|
72 |
ahart |
1.15 |
dbOtherCreate ("$ENV{'USER'}\@$ENV{'HOSTNAME'}", \@listOfFiles, $opt{"comment"});
|
73 |
ahart |
1.8 |
}
|
74 |
|
|
else
|
75 |
ahart |
1.4 |
{
|
76 |
|
|
my $id = -1;
|
77 |
ahart |
1.5 |
my $fullDataset;
|
78 |
ahart |
1.8 |
($id, $fullDataset) = getDataset ($ARGV[0], $ARGV[1]) if $ARGV[0] ne "create" && ($ARGV[0] ne "update" || !$opt{"other"}) && ($ARGV[0] ne "deleteEntry" || !$opt{"other"});
|
79 |
|
|
$id = $ARGV[1] if ($ARGV[0] eq "update" && $opt{"other"}) || ($ARGV[0] eq "deleteEntry" && $opt{"other"});
|
80 |
ahart |
1.5 |
$fullDataset = $ARGV[1] if $id < 0;
|
81 |
ahart |
1.4 |
$ARGV[0] = "create" if $id < 0;
|
82 |
|
|
my $status = "present";
|
83 |
|
|
$status = "" if $ARGV[0] eq "update";
|
84 |
|
|
$status = "deprecated" if $ARGV[0] eq "deprecate";
|
85 |
|
|
$opt{"format"} = "BEAN" if $ARGV[0] eq "create" && !$opt{"format"};
|
86 |
ahart |
1.18 |
if ($opt{"location"} && locationExists ($id, $opt{"location"}))
|
87 |
|
|
{
|
88 |
|
|
print "This location is already registered in the database!\n";
|
89 |
|
|
exit;
|
90 |
|
|
}
|
91 |
ahart |
1.26 |
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"}, $opt{"configName"}, $opt{"xSection"}, $opt{"higherOrderXSec"}) if $ARGV[0] ne "deleteEntry" && !$opt{"other"};
|
92 |
|
|
dbUpdateOther ($id, $opt{"comment"}, "$ENV{'USER'}\@$ENV{'HOSTNAME'}") if $ARGV[0] ne "deleteEntry" && $opt{"other"};
|
93 |
ahart |
1.8 |
dbDelete ($id) if $ARGV[0] eq "deleteEntry" && !$opt{"other"};
|
94 |
|
|
dbDeleteOther ($id) if $ARGV[0] eq "deleteEntry" && $opt{"other"};
|
95 |
ahart |
1.4 |
}
|
96 |
ahart |
1.1 |
|
97 |
|
|
sub
|
98 |
|
|
addSlashes
|
99 |
ahart |
1.2 |
{
|
100 |
ahart |
1.1 |
my $string = shift;
|
101 |
|
|
|
102 |
|
|
$string =~ s/\\/\\\\/g;
|
103 |
|
|
$string =~ s/'/\\'/g;
|
104 |
|
|
$string =~ s/"/\\"/g;
|
105 |
|
|
$string =~ s/\\0/\\\\0/g;
|
106 |
|
|
|
107 |
|
|
return $string;
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
sub
|
111 |
|
|
getDataset
|
112 |
|
|
{
|
113 |
ahart |
1.4 |
my $command = shift;
|
114 |
ahart |
1.1 |
my $dataset = shift;
|
115 |
|
|
|
116 |
|
|
my $results;
|
117 |
ahart |
1.3 |
my $queryDataset = $dataset;
|
118 |
|
|
$queryDataset =~ s/\*/%/g;
|
119 |
|
|
$queryDataset =~ s/(.*)/%$1%/g;
|
120 |
ahart |
1.26 |
my $query = "select id,dataset,user,creationTime,status from ntuple where dataset like '$queryDataset' order by creationTime";
|
121 |
ahart |
1.1 |
$db->selectdb ("ntuple");
|
122 |
|
|
$results = $db->query ($query);
|
123 |
|
|
if ($results->numrows () == 1)
|
124 |
|
|
{
|
125 |
|
|
my @row = $results->fetchrow ();
|
126 |
ahart |
1.5 |
return ($row[0], $row[1]);
|
127 |
ahart |
1.1 |
}
|
128 |
|
|
if ($results->numrows () == 0)
|
129 |
|
|
{
|
130 |
ahart |
1.4 |
if ($command ne "deleteEntry" && $command ne "deprecate")
|
131 |
|
|
{
|
132 |
|
|
print "Database entry does not exist. Create it? (Y/n): ";
|
133 |
|
|
my $response = <STDIN>;
|
134 |
|
|
$response =~ s/\n//g;
|
135 |
|
|
$response = "y" if !$response;
|
136 |
|
|
exit if substr (lc ($response), 0, 1) ne 'y';
|
137 |
ahart |
1.5 |
return (-1, "");
|
138 |
ahart |
1.4 |
}
|
139 |
|
|
else
|
140 |
|
|
{
|
141 |
|
|
print "Database entry does not exist.\n";
|
142 |
|
|
exit;
|
143 |
|
|
}
|
144 |
ahart |
1.1 |
}
|
145 |
ahart |
1.5 |
my %id;
|
146 |
|
|
my %fullDataset;
|
147 |
ahart |
1.1 |
print "Found multiple database entries matching\n";
|
148 |
|
|
print "\"$dataset\":\n";
|
149 |
ahart |
1.4 |
print "( 0) new\n" if $command ne "deleteEntry" && $command ne "deprecate";
|
150 |
ahart |
1.1 |
for (my $i = 1; $i <= $results->numrows (); $i++)
|
151 |
|
|
{
|
152 |
|
|
my @row = $results->fetchrow ();
|
153 |
ahart |
1.26 |
$row[3] =~ s/([^ ]*) [^ ]*/$1/g;
|
154 |
ahart |
1.5 |
$id{"$i"} = $row[0];
|
155 |
|
|
$fullDataset{"$i"} = $row[1];
|
156 |
ahart |
1.3 |
printf "(%2d) $row[1]\n", $i;
|
157 |
ahart |
1.26 |
print " (";
|
158 |
|
|
print color "green" if $row[4] eq "present";
|
159 |
|
|
print color "bold yellow" if $row[4] eq "submitted";
|
160 |
|
|
print color "bold red" if $row[4] eq "created" or $row[4] eq "cancelled" or $row[4] eq "deprecated";
|
161 |
|
|
print $row[4];
|
162 |
|
|
print color "reset";
|
163 |
|
|
print ") created by $row[2] on $row[3]\n";
|
164 |
ahart |
1.1 |
}
|
165 |
ahart |
1.4 |
print "\nWhich entry would you like to modify?";
|
166 |
|
|
if ($command ne "deleteEntry" && $command ne "deprecate")
|
167 |
|
|
{
|
168 |
|
|
print " (Select 0 to create a new entry): "
|
169 |
|
|
}
|
170 |
|
|
else
|
171 |
|
|
{
|
172 |
|
|
print ": ";
|
173 |
|
|
}
|
174 |
ahart |
1.1 |
my $response = <STDIN>;
|
175 |
|
|
$response =~ s/[ \t\n]//g;
|
176 |
ahart |
1.5 |
return (-1, "") if $response == 0 && $command ne "deleteEntry" && $command ne "deprecate";
|
177 |
|
|
if (!(exists $id{$response}))
|
178 |
ahart |
1.1 |
{
|
179 |
|
|
print "Your selection \"$response\" was not a valid option! Quitting.\n";
|
180 |
|
|
exit;
|
181 |
|
|
}
|
182 |
|
|
|
183 |
ahart |
1.5 |
return ($id{$response}, $fullDataset{$response});
|
184 |
ahart |
1.1 |
}
|
185 |
|
|
|
186 |
|
|
sub
|
187 |
|
|
dbUpdate
|
188 |
|
|
{
|
189 |
|
|
my $id = shift;
|
190 |
|
|
my $dataset = shift;
|
191 |
ahart |
1.15 |
my $userAndHost = shift;
|
192 |
ahart |
1.1 |
my $format = shift;
|
193 |
|
|
my $location = shift;
|
194 |
ahart |
1.17 |
my $name = shift;
|
195 |
ahart |
1.4 |
my $fileListName = shift;
|
196 |
ahart |
1.1 |
my $status = shift;
|
197 |
|
|
my $comment = shift;
|
198 |
|
|
my $psetName = shift;
|
199 |
|
|
my $crabCfgName = shift;
|
200 |
|
|
my $jsonFileName = shift;
|
201 |
|
|
my $lumiSummaryName = shift;
|
202 |
ahart |
1.5 |
my $release = shift;
|
203 |
ahart |
1.21 |
my $globalTag = shift;
|
204 |
ahart |
1.22 |
my $configName = shift;
|
205 |
ahart |
1.23 |
my $xSection = shift;
|
206 |
ahart |
1.25 |
my $ySection = shift;
|
207 |
|
|
|
208 |
|
|
$location = getLocation ($id) if $id > 0
|
209 |
|
|
&& !$crabCfgName
|
210 |
|
|
&& !$comment
|
211 |
|
|
&& !$format
|
212 |
|
|
&& !$globalTag
|
213 |
|
|
&& !$configName
|
214 |
|
|
&& !$jsonFileName
|
215 |
|
|
&& !$location
|
216 |
|
|
&& !$name
|
217 |
|
|
&& !$psetName
|
218 |
|
|
&& !$release
|
219 |
|
|
&& !$lumiSummaryName
|
220 |
|
|
&& !$xSection
|
221 |
|
|
&& !$ySection;
|
222 |
ahart |
1.1 |
|
223 |
ahart |
1.15 |
my $user = $userAndHost;
|
224 |
|
|
$user =~ s/@.*$//g;
|
225 |
|
|
|
226 |
ahart |
1.4 |
my $fileList;
|
227 |
ahart |
1.1 |
my $pset;
|
228 |
|
|
my $crabCfg;
|
229 |
|
|
my $jsonFile;
|
230 |
|
|
my $lumiSummary;
|
231 |
|
|
my $size = 0;
|
232 |
|
|
my $nFiles = 0;
|
233 |
ahart |
1.4 |
if ($fileListName)
|
234 |
|
|
{
|
235 |
|
|
if (!(-e $fileListName))
|
236 |
|
|
{
|
237 |
|
|
print "$fileListName does not exist!\n";
|
238 |
|
|
exit;
|
239 |
|
|
}
|
240 |
|
|
open (FILE_LIST, "<$fileListName");
|
241 |
|
|
my @fileList = <FILE_LIST>;
|
242 |
|
|
close (FILE_LIST);
|
243 |
|
|
$fileList = join ("", @fileList);
|
244 |
|
|
}
|
245 |
ahart |
1.1 |
if ($psetName)
|
246 |
|
|
{
|
247 |
|
|
if (!(-e $psetName))
|
248 |
|
|
{
|
249 |
|
|
print "$psetName does not exist!\n";
|
250 |
|
|
exit;
|
251 |
|
|
}
|
252 |
|
|
open (PY_CONFIG, "<$psetName");
|
253 |
|
|
my @pset = <PY_CONFIG>;
|
254 |
|
|
close (PY_CONFIG);
|
255 |
|
|
$pset = join ("", @pset);
|
256 |
|
|
}
|
257 |
|
|
if ($crabCfgName)
|
258 |
|
|
{
|
259 |
|
|
if (!(-e $crabCfgName))
|
260 |
|
|
{
|
261 |
|
|
print "$crabCfgName does not exist!\n";
|
262 |
|
|
exit;
|
263 |
|
|
}
|
264 |
|
|
open (CRAB_CONFIG, "<$crabCfgName");
|
265 |
|
|
my @crabCfg = <CRAB_CONFIG>;
|
266 |
|
|
close (CRAB_CONFIG);
|
267 |
|
|
$crabCfg = join ("", @crabCfg);
|
268 |
|
|
}
|
269 |
|
|
if ($jsonFileName)
|
270 |
|
|
{
|
271 |
|
|
if (!(-e $jsonFileName))
|
272 |
|
|
{
|
273 |
|
|
print "$jsonFileName does not exist!\n";
|
274 |
|
|
exit;
|
275 |
|
|
}
|
276 |
|
|
open (JSON_FILE, "<$jsonFileName");
|
277 |
|
|
my @jsonFile = <JSON_FILE>;
|
278 |
|
|
close (JSON_FILE);
|
279 |
|
|
$jsonFile = join ("", @jsonFile);
|
280 |
|
|
}
|
281 |
|
|
if ($lumiSummaryName)
|
282 |
|
|
{
|
283 |
|
|
if (!(-e $lumiSummaryName))
|
284 |
|
|
{
|
285 |
|
|
print "$lumiSummaryName does not exist!\n";
|
286 |
|
|
exit;
|
287 |
|
|
}
|
288 |
|
|
open (LUMI_SUMMARY, "<$lumiSummaryName");
|
289 |
|
|
my @lumiSummary = <LUMI_SUMMARY>;
|
290 |
|
|
close (LUMI_SUMMARY);
|
291 |
|
|
$lumiSummary = join ("", @lumiSummary);
|
292 |
|
|
}
|
293 |
ahart |
1.22 |
$release .= ".$configName" if $configName;
|
294 |
ahart |
1.25 |
($nFiles, $size) = sizeOfDataset ($location, $fileList);
|
295 |
ahart |
1.7 |
my $fullLocation = $location;
|
296 |
|
|
$fullLocation = "$ENV{'PWD'}/$location" if !($location =~ m/^\//);
|
297 |
ahart |
1.1 |
|
298 |
|
|
$dataset = addSlashes ($dataset);
|
299 |
|
|
$user = addSlashes ($user);
|
300 |
|
|
$format = addSlashes ($format);
|
301 |
|
|
$pset = addSlashes ($pset);
|
302 |
|
|
$crabCfg = addSlashes ($crabCfg);
|
303 |
|
|
$jsonFile = addSlashes ($jsonFile);
|
304 |
|
|
$lumiSummary = addSlashes ($lumiSummary);
|
305 |
ahart |
1.6 |
$fullLocation = addSlashes ($fullLocation);
|
306 |
ahart |
1.17 |
$name = addSlashes ($name);
|
307 |
ahart |
1.4 |
$fileList = addSlashes ($fileList);
|
308 |
ahart |
1.1 |
$status = addSlashes ($status);
|
309 |
|
|
$comment = addSlashes ($comment);
|
310 |
ahart |
1.5 |
$release = addSlashes ($release);
|
311 |
ahart |
1.21 |
$globalTag = addSlashes ($globalTag);
|
312 |
ahart |
1.1 |
|
313 |
|
|
my $results;
|
314 |
|
|
my $query;
|
315 |
|
|
if ($id < 0)
|
316 |
|
|
{
|
317 |
ahart |
1.16 |
$query = "select id from ntuple where dataset='$dataset'";
|
318 |
|
|
$db->selectdb ("ntuple");
|
319 |
|
|
$results = $db->query ($query);
|
320 |
|
|
if ($results->numrows ())
|
321 |
|
|
{
|
322 |
|
|
print "This dataset already exists in the database. Create anyway? (y/N): ";
|
323 |
|
|
my $response = <STDIN>;
|
324 |
|
|
$response =~ s/\n//g;
|
325 |
|
|
$response = "n" if !$response;
|
326 |
|
|
exit if substr (lc ($response), 0, 1) ne 'y';
|
327 |
|
|
}
|
328 |
|
|
|
329 |
ahart |
1.1 |
$query = "select max(id) from ntuple";
|
330 |
|
|
$db->selectdb ("ntuple");
|
331 |
|
|
$results = $db->query ($query);
|
332 |
|
|
my @row = $results->fetchrow ();
|
333 |
|
|
my $id = 1;
|
334 |
|
|
$id = $row[0] + 1 if $results->numrows ();
|
335 |
|
|
|
336 |
ahart |
1.26 |
my $columns = "(id, dataset, creationTime, lastUpdateTime, lastUpdateUser, user, format, location, fileList, nFiles, sizeInGB, status, comment, pset, crabCfg, jsonFile, lumiSummary, version, globalTag";
|
337 |
|
|
$columns .= ", crossSectionInPicobarn" if $xSection;
|
338 |
|
|
$columns .= ", higherOrderCrossSectionInPicobarn" if $ySection;
|
339 |
|
|
$columns .= ")";
|
340 |
|
|
my $values = "($id, '$dataset', now(), now(), '$userAndHost', '$user', '$format', '$fullLocation', '$fileList', $nFiles, $size, '$status', '$comment', '$pset', '$crabCfg', '$jsonFile', '$lumiSummary', '$release', '$globalTag'";
|
341 |
|
|
$values .= ", $xSection" if $xSection;
|
342 |
|
|
$values .= ", $ySection" if $ySection;
|
343 |
|
|
$values .= ")";
|
344 |
|
|
$query = "insert into ntuple $columns values $values";
|
345 |
ahart |
1.1 |
}
|
346 |
|
|
if ($id > 0)
|
347 |
|
|
{
|
348 |
|
|
my $fields;
|
349 |
|
|
my $values;
|
350 |
|
|
|
351 |
ahart |
1.17 |
if ($name)
|
352 |
|
|
{
|
353 |
|
|
$query = "select id from ntuple where dataset='$name'";
|
354 |
|
|
$db->selectdb ("ntuple");
|
355 |
|
|
$results = $db->query ($query);
|
356 |
|
|
if ($results->numrows ())
|
357 |
|
|
{
|
358 |
ahart |
1.25 |
print "This dataset already exists in the database. Use this name anyway? (y/N): ";
|
359 |
ahart |
1.17 |
my $response = <STDIN>;
|
360 |
|
|
$response =~ s/\n//g;
|
361 |
|
|
$response = "n" if !$response;
|
362 |
|
|
exit if substr (lc ($response), 0, 1) ne 'y';
|
363 |
|
|
}
|
364 |
|
|
$values .= ", dataset='$name'";
|
365 |
|
|
}
|
366 |
|
|
|
367 |
ahart |
1.1 |
$values .= ", lastUpdateTime=now()";
|
368 |
ahart |
1.9 |
$values .= ", lastUpdateUser='$user'";
|
369 |
ahart |
1.1 |
$values .= ", format='$format'" if $format;
|
370 |
ahart |
1.6 |
$values .= ", location='$fullLocation'" if $location;
|
371 |
ahart |
1.4 |
$values .= ", fileList='$fileList'" if $fileList;
|
372 |
|
|
$values .= ", nFiles=$nFiles" if $nFiles;
|
373 |
|
|
$values .= ", sizeInGB=$size" if $size;
|
374 |
ahart |
1.1 |
$values .= ", status='$status'" if $status;
|
375 |
|
|
$values .= ", comment='$comment'" if $comment;
|
376 |
|
|
$values .= ", pset='$pset'" if $pset;
|
377 |
|
|
$values .= ", crabCfg='$crabCfg'" if $crabCfg;
|
378 |
|
|
$values .= ", jsonFile='$jsonFile'" if $jsonFile;
|
379 |
|
|
$values .= ", lumiSummary='$lumiSummary'" if $lumiSummary;
|
380 |
ahart |
1.5 |
$values .= ", version='$release'" if $release;
|
381 |
ahart |
1.21 |
$values .= ", globalTag='$globalTag'" if $globalTag;
|
382 |
ahart |
1.23 |
$values .= ", crossSectionInPicobarn=$xSection" if $xSection;
|
383 |
ahart |
1.25 |
$values .= ", higherOrderCrossSectionInPicobarn=$ySection" if $ySection;
|
384 |
ahart |
1.1 |
|
385 |
|
|
$values =~ s/^, //;
|
386 |
|
|
$query = "update ntuple set $values where id=$id";
|
387 |
|
|
}
|
388 |
|
|
$results = $db->query ($query);
|
389 |
|
|
|
390 |
|
|
return $results;
|
391 |
|
|
}
|
392 |
|
|
|
393 |
|
|
sub
|
394 |
ahart |
1.8 |
dbUpdateOther
|
395 |
|
|
{
|
396 |
|
|
my $id = shift;
|
397 |
|
|
my $comment = shift;
|
398 |
ahart |
1.9 |
my $user = shift;
|
399 |
ahart |
1.8 |
|
400 |
|
|
$comment = addSlashes ($comment);
|
401 |
|
|
|
402 |
ahart |
1.9 |
my $query = "update other set lastUpdateTime=now(), lastUpdateUser='$user', comment='$comment' where id=$id";
|
403 |
ahart |
1.8 |
$db->selectdb ("ntuple");
|
404 |
|
|
my $results = $db->query ($query);
|
405 |
|
|
|
406 |
|
|
return $results;
|
407 |
|
|
}
|
408 |
|
|
|
409 |
|
|
sub
|
410 |
ahart |
1.4 |
dbDelete
|
411 |
|
|
{
|
412 |
|
|
my $id = shift;
|
413 |
|
|
|
414 |
|
|
my $query = "delete from ntuple where id=$id";
|
415 |
|
|
$db->selectdb ("ntuple");
|
416 |
|
|
my $results = $db->query ($query);
|
417 |
|
|
}
|
418 |
|
|
|
419 |
|
|
sub
|
420 |
ahart |
1.8 |
dbDeleteOther
|
421 |
|
|
{
|
422 |
|
|
my $id = shift;
|
423 |
|
|
|
424 |
|
|
my $query = "delete from other where id=$id";
|
425 |
|
|
$db->selectdb ("ntuple");
|
426 |
|
|
my $results = $db->query ($query);
|
427 |
|
|
}
|
428 |
|
|
|
429 |
|
|
sub
|
430 |
ahart |
1.1 |
printHelp
|
431 |
|
|
{
|
432 |
ahart |
1.4 |
my $command = shift;
|
433 |
|
|
|
434 |
ahart |
1.1 |
my $exeName = $0;
|
435 |
|
|
$exeName =~ s/^.*\/([^\/]*)$/$1/;
|
436 |
|
|
|
437 |
ahart |
1.4 |
if ($command eq "create")
|
438 |
|
|
{
|
439 |
|
|
print "Usage: $exeName -l DIRECTORY [OPTION]... create NAME\n";
|
440 |
|
|
print "Creates an entry in the database for dataset NAME. The ntuples are assumed to\n";
|
441 |
|
|
print "be present on the Tier 3, with the status being set accordingly.\n";
|
442 |
|
|
print "\n";
|
443 |
|
|
print "Mandatory arguments to long options are mandatory for short options too.\n";
|
444 |
|
|
printf "%-29s%s\n", " -b, --crabCfg FILE", "CRAB config used to submit ntuple jobs";
|
445 |
|
|
printf "%-29s%s\n", " -c, --comment COMMENT", "comment for the database entry";
|
446 |
|
|
printf "%-29s%s\n", " -f, --format FORMAT", "ntuple format (default: BEAN)";
|
447 |
ahart |
1.21 |
printf "%-29s%s\n", " -g, --globalTag TAG", "global tag";
|
448 |
ahart |
1.22 |
printf "%-29s%s\n", " -i, --configName NAME", "name of config used to produce ntuples";
|
449 |
ahart |
1.4 |
printf "%-29s%s\n", " -j, --jsonFile FILE", "JSON file used for this dataset";
|
450 |
|
|
printf "%-29s%s\n", " -l, --location DIRECTORY", "directory containing the ntuples";
|
451 |
|
|
printf "%-29s%s\n", " -p, --pyConfig FILE", "Python config used to produce ntuples";
|
452 |
ahart |
1.5 |
printf "%-29s%s\n", " -r, --release NAME", "ntuple release used to produce ntuples";
|
453 |
ahart |
1.4 |
printf "%-29s%s\n", " -s, --lumiSummary FILE", "lumiSummary.json reported by CRAB";
|
454 |
ahart |
1.23 |
printf "%-29s%s\n", " -x, --xSection XSEC", "cross section in picobarns for the sample";
|
455 |
ahart |
1.25 |
printf "%-29s%s\n", " -y, --higherOrderXSec XSEC", "higher-order cross section in picobarns for the";
|
456 |
|
|
printf "%-29s%s\n", " ", "sample";
|
457 |
ahart |
1.4 |
}
|
458 |
ahart |
1.8 |
elsif ($command eq "createOther")
|
459 |
|
|
{
|
460 |
|
|
print "Usage: $exeName [OPTION]... createOther DIRECTORIES_AND_FILES\n";
|
461 |
|
|
print "Creates an entry in the database for non-ntuple data.\n";
|
462 |
|
|
print "\n";
|
463 |
|
|
print "Mandatory arguments to long options are mandatory for short options too.\n";
|
464 |
|
|
printf "%-29s%s\n", " -c, --comment COMMENT", "comment for the database entry";
|
465 |
|
|
}
|
466 |
ahart |
1.4 |
elsif ($command eq "update")
|
467 |
|
|
{
|
468 |
|
|
print "Usage: $exeName [OPTION]... update NAME\n";
|
469 |
ahart |
1.25 |
print "Updates an existing database entry for dataset NAME. If no options are given,\n";
|
470 |
|
|
print "updates the number of files and the size on disk of the dataset using the\n";
|
471 |
|
|
print "location in the database.\n";
|
472 |
ahart |
1.4 |
print "\n";
|
473 |
|
|
print "Mandatory arguments to long options are mandatory for short options too.\n";
|
474 |
|
|
printf "%-29s%s\n", " -b, --crabCfg FILE", "CRAB config used to submit ntuple jobs";
|
475 |
|
|
printf "%-29s%s\n", " -c, --comment COMMENT", "comment for the database entry";
|
476 |
|
|
printf "%-29s%s\n", " -f, --format FORMAT", "ntuple format";
|
477 |
ahart |
1.21 |
printf "%-29s%s\n", " -g, --globalTag TAG", "global tag";
|
478 |
ahart |
1.22 |
printf "%-29s%s\n", " -i, --configName NAME", "name of config used to produce ntuples";
|
479 |
ahart |
1.4 |
printf "%-29s%s\n", " -j, --jsonFile FILE", "JSON file used for this dataset";
|
480 |
|
|
printf "%-29s%s\n", " -l, --location DIRECTORY", "directory containing the ntuples";
|
481 |
ahart |
1.17 |
printf "%-29s%s\n", " -n, --name NAME", "rename the entry";
|
482 |
ahart |
1.8 |
printf "%-29s%s\n", " -o, --other", "update an entry in the non-ntuple database";
|
483 |
ahart |
1.4 |
printf "%-29s%s\n", " -p, --pyConfig FILE", "Python config used to produce ntuples";
|
484 |
ahart |
1.5 |
printf "%-29s%s\n", " -r, --release NAME", "ntuple release used to produce ntuples";
|
485 |
ahart |
1.4 |
printf "%-29s%s\n", " -s, --lumiSummary FILE", "lumiSummary.json reported by CRAB";
|
486 |
ahart |
1.23 |
printf "%-29s%s\n", " -x, --xSection XSEC", "cross section in picobarns for the sample";
|
487 |
ahart |
1.25 |
printf "%-29s%s\n", " -y, --higherOrderXSec XSEC", "higher-order cross section in picobarns for the";
|
488 |
|
|
printf "%-29s%s\n", " ", "sample";
|
489 |
ahart |
1.4 |
}
|
490 |
|
|
elsif ($command eq "finish")
|
491 |
|
|
{
|
492 |
|
|
print "Usage: $exeName -l DIRECTORY finish NAME\n";
|
493 |
|
|
print "Finalizes the database entry for dataset NAME, changing its status to\n";
|
494 |
|
|
print "\"present\". This is intended to be the final step in command-line based ntuple\n";
|
495 |
|
|
print "production.\n";
|
496 |
|
|
print "\n";
|
497 |
|
|
print "Mandatory arguments to long options are mandatory for short options too.\n";
|
498 |
|
|
printf "%-29s%s\n", " -l, --location DIRECTORY", "directory containing the ntuples";
|
499 |
|
|
}
|
500 |
|
|
elsif ($command eq "deleteEntry")
|
501 |
|
|
{
|
502 |
ahart |
1.8 |
print "Usage: $exeName [OPTION]... deleteEntry NAME\n";
|
503 |
ahart |
1.4 |
print "Deletes the database entry for dataset NAME. This is intended primarily for\n";
|
504 |
|
|
print "mistaken database entries. If you wish to actually delete a set of ntuples,\n";
|
505 |
|
|
print "please use the \"deprecate\" command instead.\n";
|
506 |
ahart |
1.8 |
print "\n";
|
507 |
|
|
printf "%-29s%s\n", " -o, --other", "update an entry in the non-ntuple database";
|
508 |
ahart |
1.4 |
}
|
509 |
|
|
elsif ($command eq "deprecate")
|
510 |
|
|
{
|
511 |
|
|
print "Usage: $exeName deprecate NAME\n";
|
512 |
|
|
print "Marks the dataset NAME for deletion. WARNING: The dataset will be deleted from\n";
|
513 |
|
|
print "the Tier 3 within one week of this action. If you wish to simply delete a\n";
|
514 |
|
|
print "mistaken database entry, use the \"deleteEntry\" command instead.\n";
|
515 |
|
|
}
|
516 |
|
|
elsif ($command eq "uploadRelease")
|
517 |
|
|
{
|
518 |
ahart |
1.13 |
print "Usage: $exeName -e FILE -p FILE -r DIRECTORY [OPTION]... uploadRelease NAME\n";
|
519 |
ahart |
1.4 |
print "Copies an ntuple release to the appropriate area on the Tier 3, and creates a\n";
|
520 |
|
|
print "database entry for it, with NAME being the name of the release. An ntuple\n";
|
521 |
|
|
print "release is a CMSSW release with all the necessary packages added for creating\n";
|
522 |
|
|
print "ntuples, along with a default Python config file.\n";
|
523 |
|
|
print "\n";
|
524 |
|
|
print "Mandatory arguments to long options are mandatory for short options too.\n";
|
525 |
|
|
printf "%-29s%s\n", " -c, --comment COMMENT", "comment for the database entry";
|
526 |
ahart |
1.13 |
printf "%-29s%s\n", " -e, --recipe FILE", "file containing the recipe for the release";
|
527 |
ahart |
1.4 |
printf "%-29s%s\n", " -f, --format FORMAT", "ntuple format (default: BEAN)";
|
528 |
|
|
printf "%-29s%s\n", " -p, --pyConfig FILE", "default Python config for the release";
|
529 |
|
|
printf "%-29s%s\n", " -r, --release DIRECTORY", "CMSSW release containing ntuple packages";
|
530 |
|
|
}
|
531 |
ahart |
1.11 |
elsif ($command eq "downloadRelease")
|
532 |
|
|
{
|
533 |
|
|
print "Usage: $exeName [OPTION]... downloadRelease NAME\n";
|
534 |
|
|
print "Copies an ntuple release to the current directory on the Tier 3. Optionally\n";
|
535 |
|
|
print "copies the corresponding Python configuration file registered in the database.\n";
|
536 |
|
|
print "\n";
|
537 |
|
|
print "Mandatory arguments to long options are mandatory for short options too.\n";
|
538 |
|
|
printf "%-29s%s\n", " -p, --pyConfig FILE", "Python configuration file name";
|
539 |
|
|
}
|
540 |
ahart |
1.14 |
elsif ($command eq "uploadConfig")
|
541 |
|
|
{
|
542 |
ahart |
1.19 |
print "Usage: $exeName -p FILE -r RELEASE [OPTION]... uploadConfig NAME\n";
|
543 |
ahart |
1.14 |
print "Creates an entry in the database for a customized Python configuration file.\n";
|
544 |
|
|
print "\n";
|
545 |
|
|
print "Mandatory arguments to long options are mandatory for short options too.\n";
|
546 |
|
|
printf "%-29s%s\n", " -c, --comment COMMENT", "comment for the database entry";
|
547 |
|
|
printf "%-29s%s\n", " -p, --pyConfig FILE", "Python config file";
|
548 |
|
|
printf "%-29s%s\n", " -r, --release NAME", "ntuple release with which to use this config";
|
549 |
|
|
}
|
550 |
ahart |
1.4 |
else
|
551 |
|
|
{
|
552 |
|
|
print "Usage: $exeName [OPTION]... COMMAND NAME\n";
|
553 |
|
|
print "Manipulates entry in the OSU Tier 3 ntuple database given by NAME.\n";
|
554 |
|
|
print "\n";
|
555 |
|
|
print "Mandatory arguments to long options are mandatory for short options too.\n";
|
556 |
|
|
printf "%-29s%s\n", " -h, --help", "print help. If COMMAND is present, print help";
|
557 |
|
|
printf "%-29s%s\n", " ", "specific to COMMAND.";
|
558 |
|
|
print "\n";
|
559 |
|
|
print "COMMAND may be one of the following:\n";
|
560 |
|
|
printf "%-29s%s\n", " create", "creates the entry";
|
561 |
ahart |
1.11 |
printf "%-29s%s\n", " createOther", "creates an entry for non-ntuple data";
|
562 |
ahart |
1.4 |
printf "%-29s%s\n", " update", "updates the entry";
|
563 |
|
|
printf "%-29s%s\n", " finish", "finalizes the database entry";
|
564 |
|
|
printf "%-29s%s\n", " deleteEntry", "removes the database entry";
|
565 |
|
|
printf "%-29s%s\n", " deprecate", "marks the dataset for deletion";
|
566 |
|
|
printf "%-29s%s\n", " uploadRelease", "upload an ntuple release";
|
567 |
ahart |
1.11 |
printf "%-29s%s\n", " downloadRelease", "download an ntuple release";
|
568 |
ahart |
1.14 |
printf "%-29s%s\n", " uploadConfig", "upload an ntuple config";
|
569 |
ahart |
1.4 |
}
|
570 |
ahart |
1.1 |
|
571 |
|
|
exit;
|
572 |
|
|
}
|
573 |
ahart |
1.4 |
|
574 |
|
|
sub
|
575 |
|
|
sizeOfDataset
|
576 |
|
|
{
|
577 |
|
|
my $location = shift;
|
578 |
|
|
my $fileList = shift;
|
579 |
|
|
|
580 |
|
|
my $size = 0.0;
|
581 |
|
|
my $nFiles = 0;
|
582 |
ahart |
1.6 |
if ($location && !$fileList)
|
583 |
ahart |
1.4 |
{
|
584 |
|
|
if (!(-e $location))
|
585 |
|
|
{
|
586 |
|
|
print "$location does not exist!\n";
|
587 |
|
|
exit;
|
588 |
|
|
}
|
589 |
|
|
$nFiles = `ls $location | wc -l`;
|
590 |
|
|
$size = `du -s $location`;
|
591 |
|
|
$size =~ s/([^ ]*) .*/$1/;
|
592 |
|
|
$size /= 1024 * 1024;
|
593 |
|
|
$size = sprintf "%.2f", $size;
|
594 |
|
|
}
|
595 |
|
|
elsif ($fileList)
|
596 |
|
|
{
|
597 |
|
|
foreach my $file (split (/\n/, $fileList))
|
598 |
|
|
{
|
599 |
|
|
$nFiles++;
|
600 |
|
|
my $fileSize = `du -s $file`;
|
601 |
|
|
$fileSize =~ s/([^ ]*) .*/$1/;
|
602 |
|
|
$size += $fileSize;
|
603 |
|
|
}
|
604 |
|
|
$size /= 1024 * 1024;
|
605 |
|
|
$size = sprintf "%.2f", $size;
|
606 |
|
|
}
|
607 |
|
|
|
608 |
|
|
return ($nFiles, $size);
|
609 |
|
|
}
|
610 |
|
|
|
611 |
|
|
sub
|
612 |
|
|
uploadRelease
|
613 |
|
|
{
|
614 |
|
|
my $format = shift;
|
615 |
|
|
my $cmsswRelease = shift;
|
616 |
|
|
my $release = shift;
|
617 |
|
|
my $psetName = shift;
|
618 |
|
|
my $name = shift;
|
619 |
|
|
my $user = shift;
|
620 |
|
|
my $comment = shift;
|
621 |
ahart |
1.13 |
my $recipeName = shift;
|
622 |
ahart |
1.4 |
|
623 |
|
|
if (!(-e $psetName))
|
624 |
|
|
{
|
625 |
|
|
print "$psetName does not exist!\n";
|
626 |
|
|
exit;
|
627 |
|
|
}
|
628 |
ahart |
1.13 |
if (!(-e $recipeName))
|
629 |
|
|
{
|
630 |
|
|
print "$recipeName does not exist!\n";
|
631 |
|
|
exit;
|
632 |
|
|
}
|
633 |
ahart |
1.19 |
move ($release, "/home/osucms/public_html/releases/$name.tar.gz") or die "Ntuple releases may only be uploaded on the Tier 3, stopped";
|
634 |
ahart |
1.4 |
open (PY_CONFIG, "<$psetName");
|
635 |
|
|
my @pset = <PY_CONFIG>;
|
636 |
|
|
close (PY_CONFIG);
|
637 |
|
|
my $pset = join ("", @pset);
|
638 |
ahart |
1.13 |
open (RECIPE, "<$recipeName");
|
639 |
|
|
my @recipe = <RECIPE>;
|
640 |
|
|
close (RECIPE);
|
641 |
ahart |
1.25 |
my $recipe = join ("", @recipe);
|
642 |
ahart |
1.4 |
|
643 |
|
|
my $query = "select max(id) from ntupleRelease";
|
644 |
|
|
$db->selectdb ("ntuple");
|
645 |
|
|
my $results = $db->query ($query);
|
646 |
|
|
my @row = $results->fetchrow ();
|
647 |
|
|
my $id = 1;
|
648 |
|
|
$id = $row[0] + 1 if $results->numrows ();
|
649 |
|
|
|
650 |
|
|
$name = addSlashes ($name);
|
651 |
|
|
$pset = addSlashes ($pset);
|
652 |
|
|
$user = addSlashes ($user);
|
653 |
|
|
$format = addSlashes ($format);
|
654 |
|
|
$cmsswRelease = addSlashes ($cmsswRelease);
|
655 |
|
|
$comment = addSlashes ($comment);
|
656 |
ahart |
1.13 |
$recipe = addSlashes ($recipe);
|
657 |
ahart |
1.4 |
|
658 |
ahart |
1.13 |
my $query = "insert into ntupleRelease (id, name, pset, user, pending, format, cmsswRelease, comment, recipe) values ($id, '$name', '$pset', '$user', 1, '$format', '$cmsswRelease', '$comment', '$recipe')";
|
659 |
ahart |
1.4 |
$db->selectdb ("ntuple");
|
660 |
|
|
my $results = $db->query ($query);
|
661 |
|
|
}
|
662 |
ahart |
1.8 |
|
663 |
|
|
sub
|
664 |
ahart |
1.11 |
downloadRelease
|
665 |
|
|
{
|
666 |
|
|
my $release = shift;
|
667 |
|
|
my $pyConfigName = shift;
|
668 |
|
|
|
669 |
|
|
my $query = "select id,pset from ntupleRelease where name='$release'";
|
670 |
|
|
$db->selectdb ("ntuple");
|
671 |
|
|
my $results = $db->query ($query);
|
672 |
|
|
if ($results->numrows () != 1)
|
673 |
|
|
{
|
674 |
|
|
print "Ntuple release \"$release\" not found!\n";
|
675 |
|
|
exit;
|
676 |
|
|
}
|
677 |
|
|
if ($pyConfigName)
|
678 |
|
|
{
|
679 |
|
|
my @row = $results->fetchrow ();
|
680 |
|
|
open (PY_CONFIG, ">$pyConfigName");
|
681 |
|
|
print PY_CONFIG $row[1];
|
682 |
|
|
close (PY_CONFIG);
|
683 |
|
|
}
|
684 |
ahart |
1.20 |
`wget "http://cmshead.mps.ohio-state.edu/~osucms/releases/$release.tar.gz"`;
|
685 |
ahart |
1.11 |
}
|
686 |
|
|
|
687 |
|
|
sub
|
688 |
ahart |
1.8 |
dbOtherCreate
|
689 |
|
|
{
|
690 |
ahart |
1.15 |
my $userAndHost = shift;
|
691 |
ahart |
1.8 |
my $listOfFiles = shift;
|
692 |
|
|
my $comment = shift;
|
693 |
|
|
|
694 |
ahart |
1.15 |
my $user = $userAndHost;
|
695 |
|
|
$user =~ s/@.*$//g;
|
696 |
|
|
|
697 |
ahart |
1.8 |
my $size = 0.0;
|
698 |
|
|
my $nFiles = 0.0;
|
699 |
|
|
for (my $i = 0; $i < @$listOfFiles; $i++)
|
700 |
|
|
{
|
701 |
|
|
if (!(-e $$listOfFiles[$i]))
|
702 |
|
|
{
|
703 |
|
|
print "$$listOfFiles[$i] does not exist!\n";
|
704 |
|
|
exit;
|
705 |
|
|
}
|
706 |
|
|
$nFiles += `ls -R $$listOfFiles[$i] | grep -v ':\$' | grep -v '^\$' | wc -l`;
|
707 |
|
|
my $fileSize = `du -s $$listOfFiles[$i]`;
|
708 |
|
|
$fileSize =~ s/([^ ]*) .*/$1/;
|
709 |
|
|
$fileSize /= 1024 * 1024;
|
710 |
|
|
$size += $fileSize;
|
711 |
|
|
$$listOfFiles[$i] = "$ENV{'PWD'}/$$listOfFiles[$i]" if !($$listOfFiles[$i] =~ m/^\//);
|
712 |
|
|
}
|
713 |
|
|
$size = sprintf "%.2f", $size;
|
714 |
|
|
my $location = join ("<br />", @$listOfFiles);
|
715 |
|
|
|
716 |
|
|
my $query = "select max(id) from other";
|
717 |
|
|
$db->selectdb ("ntuple");
|
718 |
|
|
my $results = $db->query ($query);
|
719 |
|
|
my @row = $results->fetchrow ();
|
720 |
|
|
my $id = 1;
|
721 |
|
|
$id = $row[0] + 1 if $results->numrows ();
|
722 |
|
|
|
723 |
|
|
$user = addSlashes ($user);
|
724 |
|
|
$location = addSlashes ($location);
|
725 |
|
|
$comment = addSlashes ($comment);
|
726 |
|
|
|
727 |
ahart |
1.15 |
$query = "insert into other (id, creationTime, lastUpdateTime, lastUpdateUser, user, location, nFiles, sizeInGB, comment) values ($id, now(), now(), '$userAndHost', '$user', '$location', $nFiles, $size, '$comment')";
|
728 |
ahart |
1.14 |
$db->selectdb ("ntuple");
|
729 |
|
|
$results = $db->query ($query);
|
730 |
|
|
|
731 |
|
|
print "ID $id\n";
|
732 |
|
|
}
|
733 |
|
|
|
734 |
|
|
sub
|
735 |
|
|
uploadConfig
|
736 |
|
|
{
|
737 |
|
|
my $name = shift;
|
738 |
|
|
my $user = shift;
|
739 |
|
|
my $psetName = shift;
|
740 |
|
|
my $release = shift;
|
741 |
|
|
my $comment = shift;
|
742 |
|
|
|
743 |
|
|
if (!(-e $psetName))
|
744 |
|
|
{
|
745 |
|
|
print "$psetName does not exist!\n";
|
746 |
|
|
exit;
|
747 |
|
|
}
|
748 |
|
|
if ($release)
|
749 |
|
|
{
|
750 |
|
|
my $query = "select id from ntupleRelease where name='$release'";
|
751 |
|
|
$db->selectdb ("ntuple");
|
752 |
|
|
my $results = $db->query ($query);
|
753 |
|
|
if ($results->numrows () != 1)
|
754 |
|
|
{
|
755 |
|
|
print "Ntuple release \"$release\" not found!\n";
|
756 |
|
|
exit;
|
757 |
|
|
}
|
758 |
|
|
}
|
759 |
|
|
open (PSET, "<$psetName");
|
760 |
|
|
my @pset = <PSET>;
|
761 |
|
|
close (PSET);
|
762 |
|
|
my $pset = join ("", @pset);
|
763 |
|
|
|
764 |
|
|
my $query = "select max(id) from ntupleConfig";
|
765 |
ahart |
1.8 |
$db->selectdb ("ntuple");
|
766 |
|
|
my $results = $db->query ($query);
|
767 |
ahart |
1.14 |
my @row = $results->fetchrow ();
|
768 |
|
|
my $id = 1;
|
769 |
|
|
$id = $row[0] + 1 if $results->numrows ();
|
770 |
ahart |
1.8 |
|
771 |
ahart |
1.14 |
$name = addSlashes ($name);
|
772 |
|
|
$user = addSlashes ($user);
|
773 |
|
|
$pset = addSlashes ($pset);
|
774 |
|
|
$release = addSlashes ($release);
|
775 |
|
|
$comment = addSlashes ($comment);
|
776 |
|
|
|
777 |
|
|
my $query = "insert into ntupleConfig (id, name, pset, user, pending, ntupleRelease, comment) values ($id, '$name', '$pset', '$user', 1, '$release', '$comment')";
|
778 |
|
|
$db->selectdb ("ntuple");
|
779 |
|
|
$results = $db->query ($query);
|
780 |
ahart |
1.8 |
}
|
781 |
ahart |
1.16 |
|
782 |
|
|
sub
|
783 |
|
|
locationExists
|
784 |
|
|
{
|
785 |
ahart |
1.18 |
my $id = shift;
|
786 |
ahart |
1.16 |
my $location = shift;
|
787 |
|
|
|
788 |
|
|
$location =~ s/^(.*)\/+$/$1/;
|
789 |
ahart |
1.18 |
my $query = "select id from ntuple where location like '$location%' and id!=$id";
|
790 |
ahart |
1.16 |
$db->selectdb ("ntuple");
|
791 |
|
|
my $results = $db->query ($query);
|
792 |
|
|
return 1 if $results->numrows ();
|
793 |
|
|
|
794 |
|
|
if ($location =~ m/^\/store\/.*$/)
|
795 |
|
|
{
|
796 |
|
|
$location =~ s/^\/store\/(.*)$/\/data\/se\/store\/$1/;
|
797 |
|
|
}
|
798 |
|
|
elsif ($location =~ m/^\/data\/se\/store\/.*$/)
|
799 |
|
|
{
|
800 |
|
|
$location =~ s/^\/data\/se\/store\/(.*)$/\/store\/$1/;
|
801 |
|
|
}
|
802 |
|
|
|
803 |
ahart |
1.18 |
my $query = "select id from ntuple where location like '$location%' and id!=$id";
|
804 |
ahart |
1.16 |
$db->selectdb ("ntuple");
|
805 |
|
|
my $results = $db->query ($query);
|
806 |
|
|
return 1 if $results->numrows ();
|
807 |
|
|
|
808 |
|
|
return 0;
|
809 |
|
|
}
|
810 |
ahart |
1.25 |
|
811 |
|
|
sub
|
812 |
|
|
getLocation
|
813 |
|
|
{
|
814 |
|
|
my $id = shift;
|
815 |
|
|
|
816 |
|
|
my $query = "select location from ntuple where id=$id";
|
817 |
|
|
$db->selectdb ("ntuple");
|
818 |
|
|
my $results = $db->query ($query);
|
819 |
|
|
my @row = $results->fetchrow ();
|
820 |
|
|
|
821 |
|
|
return $row[0];
|
822 |
|
|
}
|