forked from CMSCompOps/WmAgentScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
findWorkflowOutput.py
executable file
·42 lines (31 loc) · 1.11 KB
/
findWorkflowOutput.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
#!/usr/bin/env python
import urllib2,urllib, httplib, sys, re, os, json, time, math, dbsTest, locale, re
import optparse, phedexSubscription
from xml.dom.minidom import getDOMImplementation
def classifyRequests(requests, dataset):
for request in requests:
name=request['request_name']
outputDatasets=phedexSubscription.outputdatasetsWorkflow('cmsweb.cern.ch',name)
for out in outputDatasets:
if dataset in out:
print name
return "None"
def main():
url='vocms204.cern.ch'
parser = optparse.OptionParser()
parser.add_option('-d', '--dataset', help='Dataset',dest='dataset')
(options,args) = parser.parse_args()
if not options.dataset:
print "Write a dataset"
sys.exit(0);
dataset=options.dataset
print "Gathering request"
conn = httplib.HTTPSConnection(url, cert_file = os.getenv('X509_USER_PROXY'), key_file = os.getenv('X509_USER_PROXY'))
r1=conn.request("GET",'/reqmgr/monitorSvc/requestmonitor')
r2=conn.getresponse()
requests = json.read(r2.read())
print "Clasifying Request"
print classifyRequests(requests, dataset)
sys.exit(0);
if __name__ == "__main__":
main()