Back to home page

Project CMSSW displayed by LXR

 
 

    


Warning, /EventFilter/Utilities/scripts/edmConfigFromDB is written in an unsupported language. File is not indexed.

0001 #!/usr/bin/env perl
0002 
0003 ################################################################################
0004 #
0005 # edmConfigFromDB
0006 # ---------------
0007 #
0008 #             11/08/2007 Philipp Schieferdecker <philipp.schieferdecker@cern.ch>
0009 ################################################################################
0010 
0011 my $usage =
0012     "USAGE:\nedmConfigFromDB\n" .
0013     "\t--v0|--v1|--test            (ConfDB version [default: v1])\n" .
0014     "\t--hltdev|--orcoff           (target db [default: hltdev])\n" .
0015     "\t--list <s>                  (list all configurations starting with <s>)\n" .
0016     "\t  [all other options are diregarded if --list <s> is specified!]\n\n" .
0017     "\t--configId <id>             (specify configuration by id)\n" .
0018     "\t--configName <name>         (specify configuration by name)\n" .
0019     "\t--runNumber <run>           (specify configuration by run)\n" .
0020     "\t  [--configId OR --configName OR --runNumber are required if --list is NOT specified!]\n\n" .
0021     "\t--versions                  (list all versions for specified configuration)\n" .
0022     "\t--packages                  (list all packages of configuration)\n" .
0023     "\t  [all options below are disregarded if --versions/--packages specified!]\n\n" .
0024     "\t--format <format>           (output format, default='Ascii')\n" .
0025     "\t--cff                       (retrieve configuration *fragment*)\n" .
0026     "\t--input <f1.root[,f2.root]> (insert PoolSource with specified fileNames)\n" .
0027     "\t--input <files.list>        (read a text file which lists input ROOT files)\n". 
0028     "\t--output <out.root>         (insert PoolOutputModule w/ specified fileName)\n" .
0029     "\t--nopsets                   (exclude all globale psets)\n" .
0030     "\t--noedsources               (exclude all edsources)\n" .
0031     "\t--noes                      (exclude all essources *and* esmodules)\n" .
0032     "\t--noessources               (exclude all essources)\n" .
0033     "\t--noesmodules               (exclude all esmodules)\n" .
0034     "\t--noservices                (exclude all services)\n" .
0035     "\t--nooutput                  (exclude all output modules)\n" .
0036     "\t--nopaths                   (exclude all paths [+=referenced seqs&mods])\n" .
0037     "\t--nosequences               (don't define sequences [+=referenced s&m])\n" .
0038     "\t--nomodules                 (don't define modules)\n" .
0039     "\t--psets <pset1[,pset2]>     (include only specified global psets)\n" .
0040     "\t--psets <-pset1[,-pset2]>   (include all global psets but the specified)\n" .
0041     "\t--essources <ess1[,ess2]>   (include only specified essources)\n" .
0042     "\t--essources <-ess1[,-ess2]> (include all essources but the specified)\n" .
0043     "\t--esmodules <esm1[,esm2]>   (include only specified esmodules)\n" .
0044     "\t--esmodules <-esm1[,-esm2]> (include all esmodules but the specified)\n" .
0045     "\t--services <svc1[,svc2]>    (include only specified services)\n" .
0046     "\t--services <-svc1[,-svc2]>  (include all services but the specified)\n" .
0047     "\t--paths <p1[,p2]>           (include only specified paths)\n" .
0048     "\t--paths <-p1[,-p2]>         (include all paths but the specified)\n" .
0049     "\t--streams <s1[,s2]>         (include only specified streams)\n" .
0050     "\t--datasets <d1[,d2]>        (include only specified datasets)\n" .
0051     "\t--sequences <s1[,s2]>       (include sequences, referenced or not!)\n" .
0052     "\t--modules <p1[,p2]>         (include modules, referenced or not!)\n" .
0053     "\t--blocks <m1::p1[,p2][,m2]> (generate parameter blocks\n" .
0054     "\t--logfile <filename>        (specify alternative to default /dev/null)\n" .
0055     "\n";
0056 
0057 die $usage if @ARGV<2;
0058 
0059 my $db_version  = "cms-project-confdb-hltdev";
0060 my $db_name     = "hltdev";
0061 my $do_list     = 0;
0062 my $do_versions = 0;
0063 my $do_packages = 0;
0064 
0065 my $list_begins_with = "";
0066 my $log_file         = "/dev/null";
0067 
0068 my %args = ();
0069 
0070 my %bool_options = ('--cff',1,
0071                     '--nopsets',1,
0072                     '--noedsources',1,
0073                     '--noes',1,
0074                     '--noessources',1,
0075                     '--noesmodules',1,
0076                     '--noservices',1,
0077                     '--nooutput',1,
0078                     '--nopaths',1,
0079                     '--nosequences',1,
0080                     '--nomodules',1
0081                     );
0082 my %options      = ('--format',1,
0083                     '--input',1,
0084                     '--output',1,
0085                     '--psets',1,
0086                     '--essources',1,
0087                     '--esmodules',1,
0088                     '--services',1,
0089                     '--paths',1,
0090                     '--sequences',1,
0091                     '--modules',1,
0092                     '--blocks',1,
0093                     '--streams',1,
0094                     '--datasets',1
0095                     );
0096 
0097 
0098 while (@ARGV) {
0099     my $arg = shift @ARGV;
0100     
0101     if ($arg eq "--logfile") {
0102         $log_file = shift @ARGV;
0103     }
0104     elsif ($arg eq "--debug") {
0105         $debug = 1;
0106     }
0107     
0108     elsif ($arg eq "--v0") {
0109         $db_version = "confdb-v0";
0110     }
0111     elsif ($arg eq "--v1") {
0112         $db_version = "cms-project-confdb-hltdev";
0113     }
0114     elsif ($arg eq "--test") {
0115         $db_version = "test--confdb";
0116     }
0117     
0118     elsif ($arg eq "--hltdev") {
0119         $db_name = "HLTDEV";
0120     }
0121     elsif ($arg eq "--orcoff") {
0122         $db_name = "ORCOFF";
0123     }
0124 
0125     elsif ($arg eq "--list") {
0126         die ("ERROR: --list doesn't allow additional options\n") if (keys %args>0);
0127         $do_list = 1;
0128         $list_begins_with = shift @ARGV;
0129         print "$ARGV\n";
0130         die ("ERROR: --list doesn't allow additional options\n") if (@ARGV > 0);
0131         last;
0132     }
0133     
0134     elsif ($arg eq "--configId") {
0135         die "ERROR: specify either --configId *or* --configName *or* --runNumber\n"
0136             if exists $args{'configName'} || exists $args{'runNumber'};
0137         $args{'configId'} = shift @ARGV;
0138         last if $do_versions || $do_packages;
0139     }
0140     elsif ($arg eq "--configName") {
0141         die "ERROR: specify either --configId *or* --configName *or* --runNumber\n"
0142             if exists $args{'configId'} || exists $args{'runNumber'};
0143         $args{'configName'} = shift @ARGV;
0144     }
0145     elsif ($arg eq "--runNumber") {
0146         die "ERROR: specify either --configId *or* --configName *or* --runNumber\n"
0147             if exists $args{'configId'} || exists $args{'configName'};
0148         $args{'runNumber'} = shift @ARGV;
0149     }
0150     elsif ($arg eq "--packages") {
0151         die "ERROR: --packages doesn't go with --versions\n" if $do_versions;
0152         $do_packages = 1;
0153         last if exists $args{'configId'} || exists $args{'configName'};
0154     }
0155     elsif ($arg eq "--versions") {
0156         die "ERROR: --versions doesn't go with --packages\n" if $do_packages;
0157         $do_versions = 1;
0158         last if exists $args{'configId'} || exists $args{'configName'};
0159     }
0160     elsif ($bool_options{$arg}) {
0161         die "ERROR: " . $arg . " invalid with --packages / --versions\n"
0162             if $do_versions || $do_packages;
0163         $arg =~ s/--//;
0164         $args{$arg} = "";
0165     }
0166     elsif ($options{$arg}) {
0167         die "ERROR: " . $arg . " invalid with --packages / --versions\n"
0168             if $do_versions || $do_packages;
0169         $arg =~ s/--//;
0170         $args{$arg} = shift @ARGV;
0171     }
0172     else {
0173         die "ERROR: invalid option $arg\n";
0174     }
0175 }
0176 
0177 my $jsp = "get.jsp";
0178 if ($do_list||$do_versions||$do_packages) { $jsp = "confdb.jsp"; }
0179 
0180 my $url = "http://www.cern.ch/" . $db_version . "/" . $jsp . "?dbName=$db_name";
0181 
0182 if ($do_list) {
0183     $url = $url . "&list=" . $list_begins_with;
0184 }
0185 else {
0186     die "ERROR: neither --list nor --configId OR --configName specified\n"
0187         if not exists $args{'configName'} and not exists $args{'configId'} and not exists $args{'runNumber'};
0188     
0189     die "ERROR: specify either -configId OR --configName\n"
0190         if exists $args{'configName'} and exists $args{'configId'};
0191     
0192     if ($args{'configId'}) {
0193         $url = $url . "&configId=" . $args{'configId'};
0194         delete $args{'configId'};
0195     }
0196     elsif ($args{'configName'}) {
0197         $url = $url . "&configName=" . $args{'configName'};
0198         delete $args{'configName'};
0199     }
0200     elsif ($args{'runNumber'}) {
0201         $url = $url . "&runNumber=" . $args{'runNumber'};
0202         delete $args{'runNumber'};
0203     }
0204         
0205 
0206     if ($do_versions) {
0207         $url = $url . "&versions=";
0208     }
0209     elsif ($do_packages) {
0210         $url = $url . "&packages=";
0211     }
0212     else {
0213         while ( my ($key,$value) = each(%args)) {
0214             if ($debug) { print ("key=$key, value=$value\n"); }
0215             $url = $url . "&" . $key . "=" . $value;
0216         }
0217     }
0218 }
0219 
0220 if ($debug) { print STDERR ("wget \"$url\" -O- -o $log_file\n"); }
0221 
0222 system("wget \"$url\" -O- -o $log_file");
0223 
0224 exit 0;