forked from CMSCompOps/WmAgentScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlistWorkflows.py
More file actions
executable file
·53 lines (43 loc) · 1.46 KB
/
listWorkflows.py
File metadata and controls
executable file
·53 lines (43 loc) · 1.46 KB
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
53
#!/usr/bin/env python -w
import sys,re,time,os
import json
import optparse
import httplib
import datetime
import shutil
#import phedexSubscription
url='cmsweb.cern.ch'
def getInputDataSet(url, workflow):
conn = httplib.HTTPSConnection(url, cert_file = os.getenv('X509_USER_PROXY'), key_file = os.getenv('X509_USER_PROXY'))
r1=conn.request("GET",'/reqmgr/reqMgr/request?requestName='+workflow)
r2=conn.getresponse()
request = json.loads(r2.read())
inputDataSets=request['InputDataset']
if len(inputDataSets)<1:
print "ERROR: No InputDataSet for workflow"
else:
return inputDataSets
def getWorkflows(state):
conn = httplib.HTTPSConnection(url, cert_file = os.getenv('X509_USER_PROXY'), key_file = os.getenv('X509_USER_PROXY'))
r1=conn.request("GET",'/couchdb/reqmgr_workload_cache/_design/ReqMgr/_view/bystatusandtype?stale=update_after')
r2=conn.getresponse()
data = json.loads(r2.read())
items = data['rows']
workflows = []
for item in items:
if state in item['key'] and ('ReReco' in item['key'] or 'ReDigi' in item['key']):
workflows.append(item['key'][0])
return workflows
def main():
args=sys.argv[1:]
if len(args) == 1:
state=args[0]
else:
state='assignment-approved'
workflows = getWorkflows(state)
for workflow in workflows:
inputDataset = getInputDataSet(url, workflow)
print workflow, inputDataset
sys.exit(0)
if __name__ == "__main__":
main()