forked from CMSCompOps/WmAgentScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phedexSubscriptionTest.py
executable file
·52 lines (46 loc) · 1.84 KB
/
phedexSubscriptionTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
import urllib2,urllib, httplib, sys, re, os, json, phedexSubscription, dbsTest
from xml.dom.minidom import getDOMImplementation
#Tests whether a dataset was subscribed to phedex
def testOutputDataset(datasetName, requestType):
url='https://cmsweb.cern.ch/phedex/datasvc/json/prod/Subscriptions?dataset=' + datasetName
result = json.read(urllib2.urlopen(url).read())
datasets=result['phedex']['dataset']
if len(datasets)>0:
dicts=datasets[0]
subscriptions=dicts['subscription']
for subscription in subscriptions:
if subscription['level']=='DATASET' and subscription['custodial']=='y':
if 'MonteCarlo' in requestType:
if subscription['custodial']=='y':
print "This dataset is subscribed : "+ datasetName
print "Custodial: "+subscription['custodial']
request=subscription['request']
print "Request page: https://cmsweb.cern.ch/phedex/prod/Request::View?request="+str(request)
return
else:
print "This dataset is subscribed : "+ datasetName
print "Custodial: "+subscription['custodial']
request=subscription['request']
print "Request page: https://cmsweb.cern.ch/phedex/prod/Request::View?request="+str(request)
return
else:
print "The Subscription exist but not custodial"
request=subscription['request']
print "Request page: https://cmsweb.cern.ch/phedex/prod/Request::View?request="+str(request)
else:
print "This dataset wasn't subscribed: "+ datasetName
def main():
args=sys.argv[1:]
if not len(args)==1:
print "usage:dbsTest workflowname"
sys.exit(0)
workflow=args[0]
url='cmsweb.cern.ch'
requestType=dbsTest.getWorkflowType(url, workflow)
datasets=phedexSubscription.outputdatasetsWorkflow(url, workflow)
for datasetName in datasets:
testOutputDataset(datasetName, requestType)
sys.exit(0);
if __name__ == "__main__":
main()