File indexing completed on 2024-04-06 12:15:59
0001 import sys
0002 import json
0003 import das_client
0004
0005 def dasFileQuery(dataset):
0006 query = 'dataset dataset=%s' % dataset
0007 host = 'https://cmsweb.cern.ch'
0008 idx = 0
0009 limit = 0
0010 debug = 0
0011 thr = 300
0012 ckey = ""
0013 cert = ""
0014 jsondict = das_client.get_data(host, query, idx, limit, debug, thr, ckey, cert)
0015
0016
0017 if not jsondict['data'] or not jsondict['data'][0]['dataset']:
0018 sys.stderr.write('Error: the pattern "%s" does not match any dataset\n' % dataset)
0019 sys.exit(1)
0020 return []
0021 elif len(jsondict['data']) > 1:
0022 sys.stderr.write('Error: the pattern "%s" matches multiple datasets\n' % dataset)
0023 for d in jsondict['data']:
0024 sys.stderr.write(' %s\n' % d['dataset'][0]['name'])
0025 sys.exit(1)
0026 return []
0027 else:
0028
0029 dataset = jsondict['data'][0]['dataset'][0]['name']
0030 query = 'file dataset=%s' % dataset
0031 jsondict = das_client.get_data(host, query, idx, limit, debug, thr, ckey, cert)
0032
0033 files = sorted( f['file'][0]['name'] for f in jsondict['data'] )
0034 return files
0035