CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
dasFileQuery Namespace Reference

Functions

def dasFileQuery
 

Function Documentation

def dasFileQuery.dasFileQuery (   dataset)

Definition at line 5 of file dasFileQuery.py.

References das_client.get_data().

5 
6 def dasFileQuery(dataset):
7  query = 'dataset dataset=%s' % dataset
8  host = 'https://cmsweb.cern.ch' # default
9  idx = 0 # default
10  limit = 0 # unlimited
11  debug = 0 # default
12  thr = 300 # default
13  ckey = "" # default
14  cert = "" # default
15  jsondict = das_client.get_data(host, query, idx, limit, debug, thr, ckey, cert)
16 
17  # check if the pattern matches none, many, or one dataset
18  if not jsondict['data'] or not jsondict['data'][0]['dataset']:
19  sys.stderr.write('Error: the pattern "%s" does not match any dataset\n' % dataset)
20  sys.exit(1)
21  return []
22  elif len(jsondict['data']) > 1:
23  sys.stderr.write('Error: the pattern "%s" matches multiple datasets\n' % dataset)
24  for d in jsondict['data']:
25  sys.stderr.write(' %s\n' % d['dataset'][0]['name'])
26  sys.exit(1)
27  return []
28  else:
29  # expand the dataset name
30  dataset = jsondict['data'][0]['dataset'][0]['name']
31  query = 'file dataset=%s' % dataset
32  jsondict = das_client.get_data(host, query, idx, limit, debug, thr, ckey, cert)
33  # parse the results in JSON format, and extract the list of files
34  files = sorted( f['file'][0]['name'] for f in jsondict['data'] )
35  return files
36 
def get_data
Definition: das_client.py:276
def dasFileQuery
Definition: dasFileQuery.py:5