ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/input.py
(Generate patch)

Comparing UserCode/MitProd/Processing/bin/input.py (file contents):
Revision 1.2 by paus, Sat Jun 5 02:36:28 2010 UTC vs.
Revision 1.5 by paus, Sat Oct 22 13:07:04 2011 UTC

# Line 2 | Line 2
2   #---------------------------------------------------------------------------------------------------
3   # Simple interface to command line DBS to prepare my crabTask input files.
4   #---------------------------------------------------------------------------------------------------
5 < import os,sys,types,string,getopt
5 > import os,sys,types,string,re,getopt
6  
7   # Define string to explain usage of the script
8   usage =  "Usage: input.py --dataset=<name>\n"
9   usage += "                --option=[ lfn, xml ]\n"
10 + usage += "                [ --dbs= ]\n"
11   usage += "                --help\n"
12  
13   def printLine(option,nEvents,block,lfn,iJob):
# Line 18 | Line 19 | def printLine(option,nEvents,block,lfn,i
19  
20      
21   # Define the valid options which can be specified and check out the command line
22 < valid = ['db=','dataset=','option=','help']
22 > valid = ['db=','dbs=','dataset=','option=','help']
23   try:
24      opts, args = getopt.getopt(sys.argv[1:], "", valid)
25   except getopt.GetoptError, ex:
# Line 31 | Line 32 | except getopt.GetoptError, ex:
32   # --------------------------------------------------------------------------------------------------
33   # Set defaults for each option
34   db      = None
35 + dbs     = None
36   dataset = None
37   option  = 'lfn'
38  
# Line 41 | Line 43 | for opt, arg in opts:
43          sys.exit(0)
44      if opt == "--db":
45          db      = arg
46 +    if opt == "--dbs":
47 +        dbs     = arg
48      if opt == "--dataset":
49          dataset = arg
50      if opt == "--option":
# Line 56 | Line 60 | if dataset == None:
60   #---------------------------------------------------------------------------------------------------
61   if not db:
62      # find relevant blocks
63 <    cmd  = "dbs search --query=\"find block where dataset=" + dataset + "\""
63 >    if   dbs == 'none':
64 >        cmd = 'dascli.py --query="block=' + dataset + '*" --limit=999999 --format=blocks'
65 >    elif dbs == '':
66 >        cmd = 'dbs search --query=\"find block where dataset=' + dataset + '\"'
67 >    elif re.search('http://',dbs):
68 >        cmd = 'dbs search --url=' + dbs + ' --query="find block where dataset=' + dataset + '"'
69 >    else:
70 >        cmd = 'echo ' + dataset + '#00000000-0000-0000-0000-000000000000'
71 >
72 >    #print "CMD " + cmd
73      cmd += "| grep \# | sort"
74 +    # never print #print "cmd: " + cmd
75 +
76      blocks = []
77      iJob = 1
78      if option == 'xml':
# Line 66 | Line 81 | if not db:
81          line = line[:-1]
82          blocks.append(line)
83      for block in blocks:
84 <        cmd  = "dbs search --query=\"find file,file.numevents where block=" + block + "\""
84 >        #print ' BLOCK: ' + block
85 >
86 >        if   dbs == 'none':
87 >            cmd = 'dascli.py --query="file block=' + block + '" --limit=999999 --format=files'
88 >        elif dbs == '':
89 >            cmd = 'dbs search --query="find file,file.numevents where block=' + block + '"'
90 >        elif re.search('http://',dbs):
91 >            cmd = 'dbs search --url=' + dbs + \
92 >                  ' --query="find file,file.numevents where block=' + block + '"'
93 >        else:
94 >            cmd = 'cat /home/cmsprod/catalog/t2mit/private/' + dbs + dataset \
95 >                  + '/Files | sed \'s@XX-CATALOG-XX@@\' | sed \'s@root://xrootd1.cmsaf.mit.edu/@@\''
96 >            
97 >        #print "CMD " + cmd
98          cmd += "| grep store | sort"
99          for line in os.popen(cmd).readlines():
100 +            #print "LINE >" + line
101              line = line[:-1]
102              f       = line.split()
103              lfn     = f[0]

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines