Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:14:47

0001 from __future__ import print_function
0002 from das_client import get_data
0003 import subprocess
0004 #from pdb import set_trace
0005 
0006 def query(query_str, verbose=False):
0007    'simple query function to interface with DAS, better than using Popen as everything is handled by python'
0008    if verbose:
0009       print('querying DAS with: "%s"' % query_str)
0010    data = get_data(
0011       'https://cmsweb.cern.ch', 
0012       query_str,
0013       0, 0, False)
0014 
0015    to_get = query_str.split()[0].strip(',')
0016    if data['status'] != 'ok':
0017       raise RuntimeError('Das query crashed')
0018 
0019    #-1 works both when getting dataset from files and files from datasets, 
0020    #not checked on everything
0021    return [i[to_get][-1]['name'] for i in data['data']]