Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
HLTrigger
Configuration
python
Tools
dasFileQuery.py
Go to the documentation of this file.
1
import
sys
2
import
json
3
import
das_client
4
5
def
dasFileQuery
(dataset):
6
query =
'dataset dataset=%s'
% dataset
7
host =
'https://cmsweb.cern.ch'
# default
8
idx = 0
# default
9
limit = 0
# unlimited
10
debug = 0
# default
11
thr = 300
# default
12
ckey =
""
# default
13
cert =
""
# default
14
jsondict = das_client.get_data(host, query, idx, limit, debug, thr, ckey, cert)
15
16
# check if the pattern matches none, many, or one dataset
17
if
not
jsondict[
'data'
]
or
not
jsondict[
'data'
][0][
'dataset'
]:
18
sys.stderr.write(
'Error: the pattern "%s" does not match any dataset\n'
% dataset)
19
sys.exit(1)
20
return
[]
21
elif
len(jsondict[
'data'
]) > 1:
22
sys.stderr.write(
'Error: the pattern "%s" matches multiple datasets\n'
% dataset)
23
for
d
in
jsondict[
'data'
]:
24
sys.stderr.write(
' %s\n'
% d[
'dataset'
][0][
'name'
])
25
sys.exit(1)
26
return
[]
27
else
:
28
# expand the dataset name
29
dataset = jsondict[
'data'
][0][
'dataset'
][0][
'name'
]
30
query =
'file dataset=%s'
% dataset
31
jsondict = das_client.get_data(host, query, idx, limit, debug, thr, ckey, cert)
32
# parse the results in JSON format, and extract the list of files
33
files = sorted( f[
'file'
][0][
'name'
]
for
f
in
jsondict[
'data'
] )
34
return
files
35
dasFileQuery.dasFileQuery
def dasFileQuery
Definition:
dasFileQuery.py:5
Generated for CMSSW Reference Manual by
1.8.5