CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
electronDbsDiscovery Namespace Reference

Functions

def common_search
 
def search
 
def search2
 

Variables

tuple files = dbs.search()
 

Function Documentation

def electronDbsDiscovery.common_search (   dbs_tier)

Definition at line 42 of file electronDbsDiscovery.py.

Referenced by search(), and search2().

42 
43 def common_search(dbs_tier):
44 
45  if os.environ['DBS_STRATEGY'] == "local":
46 
47  result = []
48  for line in open('electronDbsDiscovery.txt').readlines():
49  line = os.path.expandvars(line.strip())
50  if line == "": continue
51  if os.environ['DBS_SAMPLE'] != "Any" and line.find(os.environ['DBS_SAMPLE'])== -1: continue
52  if line.find(os.environ['DBS_COND'])== -1: continue
53  if line.find(dbs_tier)== -1: continue
54  result.append('file:'+line)
55 
56  elif os.environ['DBS_STRATEGY'] == "castor":
57 
58  castor_dir = '/castor/cern.ch/cms/store/relval/'+os.environ['DBS_RELEASE']+'/'+os.environ['DBS_SAMPLE']+'/'+os.environ['DBS_TIER']+'/'+os.environ['DBS_COND']+'/'
59  if __name__ == "__main__":
60  print 'castor dir:',castor_dir
61  result = []
62  data = os.popen('rfdir '+castor_dir)
63  subdirs = data.readlines()
64  data.close()
65  datalines = []
66  for line in subdirs:
67  line = line.rstrip()
68  subdir = line.split()[8]
69  data = os.popen('rfdir '+castor_dir+'/'+subdir)
70  datalines = data.readlines()
71  for line in datalines:
72  line = line.rstrip()
73  file = line.split()[8]
74  if file != "":
75  result.append('/store/relval/'+os.environ['DBS_RELEASE']+'/'+os.environ['DBS_SAMPLE']+'/'+os.environ['DBS_TIER']+'/'+os.environ['DBS_COND']+'/'+subdir+'/'+file)
76  data.close()
77 
78  elif os.environ['DBS_STRATEGY'] == "lsf":
79 
80  dbs_path = '/'+os.environ['DBS_SAMPLE']+'/'+os.environ['DBS_RELEASE']+'-'+os.environ['DBS_COND']+'/'+os.environ['DBS_TIER']+'"'
81  if __name__ == "__main__":
82  print 'dbs path:',dbs_path
83  data = os.popen('dbs lsf --path="'+dbs_path+'"')
84  datalines = data.readlines()
85  data.close()
86  result = []
87  for line in datalines:
88  line = line.rstrip()
89  if line != "" and line[0] =="/":
90  result.append(line)
91 
92  else:
93 
94  input = "find file"
95  separator = " where "
96  if os.environ['DBS_RELEASE'] != "Any":
97  input = input + separator + "release = " + os.environ['DBS_RELEASE']
98  separator = " and "
99  if os.environ['DBS_SAMPLE'] != "Any":
100  input = input + separator + "primds = " + os.environ['DBS_SAMPLE']
101  separator = " and "
102  if os.environ['DBS_RUN'] != "Any":
103  input = input + separator + "run = " + os.environ['DBS_RUN']
104  separator = " and "
105  input = input + separator + "dataset like *" + os.environ['DBS_COND'] + "*" + dbs_tier + "*"
106 
107  #url = "https://cmsweb.cern.ch:443/dbs_discovery/aSearch"
108  #final_input = urllib.quote(input) ;
109  #
110  #agent = "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)"
111  #ctypes = "text/plain"
112  #headers = { 'User-Agent':agent, 'Accept':ctypes}
113  #params = {'dbsInst':'cms_dbs_prod_global',
114  # 'html':0,'caseSensitive':'on','_idx':0,'pagerStep':-1,
115  # 'userInput':final_input,
116  # 'xml':0,'details':0,'cff':0,'method':'dbsapi'}
117  #data = urllib.urlencode(params,doseq=True)
118  #req = urllib2.Request(url, data, headers)
119  #data = ""
120  #
121  #try:
122  # response = urllib2.urlopen(req)
123  # data = response.read()
124  #except urllib2.HTTPError, e:
125  # if e.code==201:
126  # print e.headers
127  # print e.msg
128  # pass
129  # else:
130  # raise e
131 
132  data = os.popen('dbs search --url="http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet" --query "'+input+'"')
133  datalines = data.readlines()
134  data.close()
135  result = []
136  for line in datalines:
137  line = line.rstrip()
138  if line != "" and line[0] =="/":
139  result.append(line)
140 
141  return result
def electronDbsDiscovery.search ( )

Definition at line 142 of file electronDbsDiscovery.py.

References common_search().

Referenced by AlignmentMonitorTemplate.event(), FileNamesHelper.getJobID_fromFileName(), and duplicateReflexLibrarySearch.searchClassDefXml().

143 def search():
144  return common_search(os.environ['DBS_TIER'])
def electronDbsDiscovery.search2 ( )

Definition at line 145 of file electronDbsDiscovery.py.

References common_search().

146 def search2():
147  return common_search(os.environ['DBS_TIER_SECONDARY'])
148 
149 
150 
151 

Variable Documentation

tuple electronDbsDiscovery.files = dbs.search()

Definition at line 8 of file electronDbsDiscovery.py.