|
1 | 1 | #!/usr/bin/env perl |
2 | 2 |
|
3 | | -################################################################################ |
4 | | -# |
5 | | -# edmConfigFromDB |
6 | | -# --------------- |
7 | | -# |
8 | | -# 11/08/2007 Philipp Schieferdecker <[email protected]> |
9 | | -################################################################################ |
10 | | - |
11 | | -my $usage = |
12 | | - "USAGE:\nedmConfigFromDB\n" . |
13 | | - "\t--v0|--v1|--test (ConfDB version [default: v1])\n" . |
14 | | - "\t--hltdev|--orcoff (target db [default: hltdev])\n" . |
15 | | - "\t--list <s> (list all configurations starting with <s>)\n" . |
16 | | - "\t [all other options are diregarded if --list <s> is specified!]\n\n" . |
17 | | - "\t--configId <id> (specify configuration by id)\n" . |
18 | | - "\t--configName <name> (specify configuration by name)\n" . |
19 | | - "\t--runNumber <run> (specify configuration by run)\n" . |
20 | | - "\t [--configId OR --configName OR --runNumber are required if --list is NOT specified!]\n\n" . |
21 | | - "\t--versions (list all versions for specified configuration)\n" . |
22 | | - "\t--packages (list all packages of configuration)\n" . |
23 | | - "\t [all options below are disregarded if --versions/--packages specified!]\n\n" . |
24 | | - "\t--format <format> (output format, default='Ascii')\n" . |
25 | | - "\t--cff (retrieve configuration *fragment*)\n" . |
26 | | - "\t--input <f1.root[,f2.root]> (insert PoolSource with specified fileNames)\n" . |
27 | | - "\t--input <files.list> (read a text file which lists input ROOT files)\n". |
28 | | - "\t--output <out.root> (insert PoolOutputModule w/ specified fileName)\n" . |
29 | | - "\t--nopsets (exclude all globale psets)\n" . |
30 | | - "\t--noedsources (exclude all edsources)\n" . |
31 | | - "\t--noes (exclude all essources *and* esmodules)\n" . |
32 | | - "\t--noessources (exclude all essources)\n" . |
33 | | - "\t--noesmodules (exclude all esmodules)\n" . |
34 | | - "\t--noservices (exclude all services)\n" . |
35 | | - "\t--nooutput (exclude all output modules)\n" . |
36 | | - "\t--nopaths (exclude all paths [+=referenced seqs&mods])\n" . |
37 | | - "\t--nosequences (don't define sequences [+=referenced s&m])\n" . |
38 | | - "\t--nomodules (don't define modules)\n" . |
39 | | - "\t--psets <pset1[,pset2]> (include only specified global psets)\n" . |
40 | | - "\t--psets <-pset1[,-pset2]> (include all global psets but the specified)\n" . |
41 | | - "\t--essources <ess1[,ess2]> (include only specified essources)\n" . |
42 | | - "\t--essources <-ess1[,-ess2]> (include all essources but the specified)\n" . |
43 | | - "\t--esmodules <esm1[,esm2]> (include only specified esmodules)\n" . |
44 | | - "\t--esmodules <-esm1[,-esm2]> (include all esmodules but the specified)\n" . |
45 | | - "\t--services <svc1[,svc2]> (include only specified services)\n" . |
46 | | - "\t--services <-svc1[,-svc2]> (include all services but the specified)\n" . |
47 | | - "\t--paths <p1[,p2]> (include only specified paths)\n" . |
48 | | - "\t--paths <-p1[,-p2]> (include all paths but the specified)\n" . |
49 | | - "\t--streams <s1[,s2]> (include only specified streams)\n" . |
50 | | - "\t--datasets <d1[,d2]> (include only specified datasets)\n" . |
51 | | - "\t--sequences <s1[,s2]> (include sequences, referenced or not!)\n" . |
52 | | - "\t--modules <p1[,p2]> (include modules, referenced or not!)\n" . |
53 | | - "\t--blocks <m1::p1[,p2][,m2]> (generate parameter blocks\n" . |
54 | | - "\t--logfile <filename> (specify alternative to default /dev/null)\n" . |
55 | | - "\n"; |
56 | | - |
57 | | -die $usage if @ARGV<2; |
58 | | - |
59 | | -my $db_version = "cms-project-confdb-hltdev"; |
60 | | -my $db_name = "hltdev"; |
61 | | -my $do_list = 0; |
62 | | -my $do_versions = 0; |
63 | | -my $do_packages = 0; |
64 | | - |
65 | | -my $list_begins_with = ""; |
66 | | -my $log_file = "/dev/null"; |
67 | | - |
68 | | -my %args = (); |
69 | | - |
70 | | -my %bool_options = ('--cff',1, |
71 | | - '--nopsets',1, |
72 | | - '--noedsources',1, |
73 | | - '--noes',1, |
74 | | - '--noessources',1, |
75 | | - '--noesmodules',1, |
76 | | - '--noservices',1, |
77 | | - '--nooutput',1, |
78 | | - '--nopaths',1, |
79 | | - '--nosequences',1, |
80 | | - '--nomodules',1 |
81 | | - ); |
82 | | -my %options = ('--format',1, |
83 | | - '--input',1, |
84 | | - '--output',1, |
85 | | - '--psets',1, |
86 | | - '--essources',1, |
87 | | - '--esmodules',1, |
88 | | - '--services',1, |
89 | | - '--paths',1, |
90 | | - '--sequences',1, |
91 | | - '--modules',1, |
92 | | - '--blocks',1, |
93 | | - '--streams',1, |
94 | | - '--datasets',1 |
95 | | - ); |
96 | | - |
97 | | - |
98 | | -while (@ARGV) { |
99 | | - my $arg = shift @ARGV; |
100 | | - |
101 | | - if ($arg eq "--logfile") { |
102 | | - $log_file = shift @ARGV; |
103 | | - } |
104 | | - elsif ($arg eq "--debug") { |
105 | | - $debug = 1; |
106 | | - } |
107 | | - |
108 | | - elsif ($arg eq "--v0") { |
109 | | - $db_version = "confdb-v0"; |
110 | | - } |
111 | | - elsif ($arg eq "--v1") { |
112 | | - $db_version = "cms-project-confdb-hltdev"; |
113 | | - } |
114 | | - elsif ($arg eq "--test") { |
115 | | - $db_version = "test--confdb"; |
116 | | - } |
117 | | - |
118 | | - elsif ($arg eq "--hltdev") { |
119 | | - $db_name = "HLTDEV"; |
120 | | - } |
121 | | - elsif ($arg eq "--orcoff") { |
122 | | - $db_name = "ORCOFF"; |
123 | | - } |
124 | | - |
125 | | - elsif ($arg eq "--list") { |
126 | | - die ("ERROR: --list doesn't allow additional options\n") if (keys %args>0); |
127 | | - $do_list = 1; |
128 | | - $list_begins_with = shift @ARGV; |
129 | | - print "$ARGV\n"; |
130 | | - die ("ERROR: --list doesn't allow additional options\n") if (@ARGV > 0); |
131 | | - last; |
132 | | - } |
133 | | - |
134 | | - elsif ($arg eq "--configId") { |
135 | | - die "ERROR: specify either --configId *or* --configName *or* --runNumber\n" |
136 | | - if exists $args{'configName'} || exists $args{'runNumber'}; |
137 | | - $args{'configId'} = shift @ARGV; |
138 | | - last if $do_versions || $do_packages; |
139 | | - } |
140 | | - elsif ($arg eq "--configName") { |
141 | | - die "ERROR: specify either --configId *or* --configName *or* --runNumber\n" |
142 | | - if exists $args{'configId'} || exists $args{'runNumber'}; |
143 | | - $args{'configName'} = shift @ARGV; |
144 | | - } |
145 | | - elsif ($arg eq "--runNumber") { |
146 | | - die "ERROR: specify either --configId *or* --configName *or* --runNumber\n" |
147 | | - if exists $args{'configId'} || exists $args{'configName'}; |
148 | | - $args{'runNumber'} = shift @ARGV; |
149 | | - } |
150 | | - elsif ($arg eq "--packages") { |
151 | | - die "ERROR: --packages doesn't go with --versions\n" if $do_versions; |
152 | | - $do_packages = 1; |
153 | | - last if exists $args{'configId'} || exists $args{'configName'}; |
154 | | - } |
155 | | - elsif ($arg eq "--versions") { |
156 | | - die "ERROR: --versions doesn't go with --packages\n" if $do_packages; |
157 | | - $do_versions = 1; |
158 | | - last if exists $args{'configId'} || exists $args{'configName'}; |
159 | | - } |
160 | | - elsif ($bool_options{$arg}) { |
161 | | - die "ERROR: " . $arg . " invalid with --packages / --versions\n" |
162 | | - if $do_versions || $do_packages; |
163 | | - $arg =~ s/--//; |
164 | | - $args{$arg} = ""; |
165 | | - } |
166 | | - elsif ($options{$arg}) { |
167 | | - die "ERROR: " . $arg . " invalid with --packages / --versions\n" |
168 | | - if $do_versions || $do_packages; |
169 | | - $arg =~ s/--//; |
170 | | - $args{$arg} = shift @ARGV; |
171 | | - } |
172 | | - else { |
173 | | - die "ERROR: invalid option $arg\n"; |
174 | | - } |
175 | | -} |
176 | | - |
177 | | -my $jsp = "get.jsp"; |
178 | | -if ($do_list||$do_versions||$do_packages) { $jsp = "confdb.jsp"; } |
179 | | - |
180 | | -my $url = "http://www.cern.ch/" . $db_version . "/" . $jsp . "?dbName=$db_name"; |
181 | | - |
182 | | -if ($do_list) { |
183 | | - $url = $url . "&list=" . $list_begins_with; |
184 | | -} |
185 | | -else { |
186 | | - die "ERROR: neither --list nor --configId OR --configName specified\n" |
187 | | - if not exists $args{'configName'} and not exists $args{'configId'} and not exists $args{'runNumber'}; |
188 | | - |
189 | | - die "ERROR: specify either -configId OR --configName\n" |
190 | | - if exists $args{'configName'} and exists $args{'configId'}; |
191 | | - |
192 | | - if ($args{'configId'}) { |
193 | | - $url = $url . "&configId=" . $args{'configId'}; |
194 | | - delete $args{'configId'}; |
195 | | - } |
196 | | - elsif ($args{'configName'}) { |
197 | | - $url = $url . "&configName=" . $args{'configName'}; |
198 | | - delete $args{'configName'}; |
199 | | - } |
200 | | - elsif ($args{'runNumber'}) { |
201 | | - $url = $url . "&runNumber=" . $args{'runNumber'}; |
202 | | - delete $args{'runNumber'}; |
203 | | - } |
204 | | - |
205 | | - |
206 | | - if ($do_versions) { |
207 | | - $url = $url . "&versions="; |
208 | | - } |
209 | | - elsif ($do_packages) { |
210 | | - $url = $url . "&packages="; |
211 | | - } |
212 | | - else { |
213 | | - while ( my ($key,$value) = each(%args)) { |
214 | | - if ($debug) { print ("key=$key, value=$value\n"); } |
215 | | - $url = $url . "&" . $key . "=" . $value; |
216 | | - } |
217 | | - } |
218 | | -} |
219 | | - |
220 | | -if ($debug) { print STDERR ("wget \"$url\" -O- -o $log_file\n"); } |
221 | | - |
222 | | -system("wget \"$url\" -O- -o $log_file"); |
223 | | - |
224 | | -exit 0; |
| 3 | +die "\e[1;31m*** ERROR ***\e[0m \e[1;33mFor Run 3, this script has been replaced by \e[1;32mhltConfigFromDB\e[0m\n"; |
0 commit comments