00011 :
00012
00013 if os.environ['DBS_LIKE'] == "LOCAL":
00014 fileIn = open("Listfiles.txt","r")
00015 line = fileIn.readline()
00016 result = []
00017 while line:
00018 for fragment in line.split("\n"):
00019 if fragment != "":
00020 result.append(fragment)
00021 line = fileIn.readline()
00022 else:
00023 url = "https://cmsweb.cern.ch:443/dbs_discovery/aSearch"
00024 input = "find file where release = " + os.environ['DBS_RELEASE']
00025 input = input + " and primds = " + os.environ['DBS_SAMPLE']
00026 input = input + " and dataset like " + os.environ['DBS_LIKE']
00027 final_input = urllib.quote(input) ;
00028
00029 agent = "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)"
00030 ctypes = "text/plain"
00031 headers = { 'User-Agent':agent, 'Accept':ctypes}
00032 params = {'dbsInst':'cms_dbs_prod_global',
00033 'html':0,'caseSensitive':'on','_idx':0,'pagerStep':-1,
00034 'userInput':final_input,
00035 'xml':0,'details':0,'cff':0,'method':'dbsapi'}
00036 data = urllib.urlencode(params,doseq=True)
00037 req = urllib2.Request(url, data, headers)
00038 data = ""
00039
00040 try:
00041 response = urllib2.urlopen(req)
00042 data = response.read()
00043 except urllib2.HTTPError, e:
00044 if e.code==201:
00045 print e.headers
00046 print e.msg
00047 pass
00048 else:
00049 raise e
00050
00051 result = []
00052 for line in data.split("\n"):
00053 if line != "" and line[0] =="/":
00054 result.append(line)
00055
00056 return result