CMS 3D CMS Logo

das.py
Go to the documentation of this file.
1 from __future__ import print_function
2 from das_client import get_data
3 import subprocess
4 #from pdb import set_trace
5 
6 def query(query_str, verbose=False):
7  'simple query function to interface with DAS, better than using Popen as everything is handled by python'
8  if verbose:
9  print('querying DAS with: "%s"' % query_str)
10  data = get_data(
11  'https://cmsweb.cern.ch',
12  query_str,
13  0, 0, False)
14 
15  to_get = query_str.split()[0].strip(',')
16  if data['status'] != 'ok':
17  raise RuntimeError('Das query crashed')
18 
19  #-1 works both when getting dataset from files and files from datasets,
20  #not checked on everything
21  return [i[to_get][-1]['name'] for i in data['data']]
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def query(query_str, verbose=False)
Definition: das.py:6
def get_data(host, query, idx, limit, debug)
Definition: das.py:71