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 45 of file electronDbsDiscovery.py.

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

def electronDbsDiscovery::search ( )

Definition at line 143 of file electronDbsDiscovery.py.

Referenced by AlignmentMonitorTemplate::event().

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

def electronDbsDiscovery::search2 ( )

Definition at line 146 of file electronDbsDiscovery.py.

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

Variable Documentation

tuple electronDbsDiscovery::files = dbs.search()

Definition at line 10 of file electronDbsDiscovery.py.