CMS 3D CMS Logo

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.

00043                            :
00044 
00045   if os.environ['DBS_STRATEGY'] == "local":
00046   
00047     result = []
00048     for line in  open('electronDbsDiscovery.txt').readlines():
00049       line = os.path.expandvars(line.strip())
00050       if line == "": continue
00051       if os.environ['DBS_SAMPLE'] != "Any" and line.find(os.environ['DBS_SAMPLE'])== -1: continue
00052       if line.find(os.environ['DBS_COND'])== -1: continue
00053       if line.find(dbs_tier)== -1: continue
00054       result.append('file:'+line)
00055       
00056   elif os.environ['DBS_STRATEGY'] == "castor":
00057   
00058     castor_dir = '/castor/cern.ch/cms/store/relval/'+os.environ['DBS_RELEASE']+'/'+os.environ['DBS_SAMPLE']+'/'+os.environ['DBS_TIER']+'/'+os.environ['DBS_COND']+'/'
00059     if __name__ == "__main__":
00060       print 'castor dir:',castor_dir
00061     result = []
00062     data = os.popen('rfdir '+castor_dir)
00063     subdirs = data.readlines()
00064     data.close()
00065     datalines = []
00066     for line in subdirs:
00067       line = line.rstrip()
00068       subdir = line.split()[8]
00069       data = os.popen('rfdir '+castor_dir+'/'+subdir)
00070       datalines = data.readlines()
00071       for line in datalines:
00072         line = line.rstrip()
00073         file = line.split()[8]
00074         if file != "":
00075           result.append('/store/relval/'+os.environ['DBS_RELEASE']+'/'+os.environ['DBS_SAMPLE']+'/'+os.environ['DBS_TIER']+'/'+os.environ['DBS_COND']+'/'+subdir+'/'+file)
00076       data.close()
00077       
00078   elif os.environ['DBS_STRATEGY'] == "lsf":
00079   
00080     dbs_path = '/'+os.environ['DBS_SAMPLE']+'/'+os.environ['DBS_RELEASE']+'-'+os.environ['DBS_COND']+'/'+os.environ['DBS_TIER']+'"'
00081     if __name__ == "__main__":
00082       print 'dbs path:',dbs_path
00083     data = os.popen('dbs lsf --path="'+dbs_path+'"')
00084     datalines = data.readlines()
00085     data.close()
00086     result = []
00087     for line in datalines:
00088       line = line.rstrip()
00089       if line != "" and line[0] =="/":
00090         result.append(line)
00091       
00092   else:
00093   
00094     input = "find file"
00095     separator = " where "
00096     if os.environ['DBS_RELEASE'] != "Any":
00097       input = input + separator + "release = " + os.environ['DBS_RELEASE']
00098       separator = " and "
00099     if os.environ['DBS_SAMPLE'] != "Any":
00100       input = input + separator + "primds = " + os.environ['DBS_SAMPLE']
00101       separator = " and "
00102     if os.environ['DBS_RUN'] != "Any":
00103       input = input + separator + "run = " + os.environ['DBS_RUN']
00104       separator = " and "
00105     input = input + separator + "dataset like *" + os.environ['DBS_COND'] + "*" + dbs_tier + "*"
00106     
00107     #url = "https://cmsweb.cern.ch:443/dbs_discovery/aSearch"
00108     #final_input = urllib.quote(input) ;
00109     #
00110     #agent   = "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)"
00111     #ctypes  = "text/plain"
00112     #headers = { 'User-Agent':agent, 'Accept':ctypes}
00113     #params  = {'dbsInst':'cms_dbs_prod_global',
00114     #           'html':0,'caseSensitive':'on','_idx':0,'pagerStep':-1,
00115     #           'userInput':final_input,
00116     #           'xml':0,'details':0,'cff':0,'method':'dbsapi'}
00117     #data    = urllib.urlencode(params,doseq=True)
00118     #req     = urllib2.Request(url, data, headers)
00119     #data    = ""
00120     #
00121     #try:
00122     #  response = urllib2.urlopen(req)
00123     #  data = response.read()
00124     #except urllib2.HTTPError, e:
00125     #  if e.code==201:
00126     #    print e.headers       
00127     #    print e.msg
00128     #    pass
00129     #  else:
00130     #    raise e
00131 
00132     data = os.popen('dbs search --url="https://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet" --query "'+input+'"')
00133     datalines = data.readlines()
00134     data.close()
00135     result = []
00136     for line in datalines:
00137       line = line.rstrip()
00138       if line != "" and line[0] =="/":
00139         result.append(line)
00140     
00141   return result

def electronDbsDiscovery::search ( )

Definition at line 142 of file electronDbsDiscovery.py.

Referenced by AlignmentMonitorTemplate::event().

00143             :
00144   return common_search(os.environ['DBS_TIER'])

def electronDbsDiscovery::search2 ( )

Definition at line 145 of file electronDbsDiscovery.py.

00146              :
00147   return common_search(os.environ['DBS_TIER_SECONDARY'])
00148 
00149         
00150         
00151 

Variable Documentation

tuple electronDbsDiscovery::files = dbs.search()

Definition at line 8 of file electronDbsDiscovery.py.