forked from CMSCompOps/WmAgentScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrejectWorkflows.py
34 lines (31 loc) · 887 Bytes
/
rejectWorkflows.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
#!/usr/bin/env python
"""
Reject a given list of workflows.
This can be used when input workflows are in status: assigened or assignment-approved
input arg: Text file with list of workflows.
"""
import urllib2,urllib, httplib, sys, re, os
try:
import json
except:
import simplejson as json
import reqMgrClient
def main():
"""
Read the text file, for each workflow try:
First reject it, then clone it.
"""
args=sys.argv[1:]
if not len(args)==1:
print "usage:rejectWorkflows file.txt"
sys.exit(0)
url='cmsweb.cern.ch'
filename=args[0]
workflows = [wf.strip() for wf in open(filename).readlines() if wf.strip()]
for workflow in workflows:
print "Rejecting workflow: " + workflow
reqMgrClient.rejectWorkflow(url, workflow)
print "Rejected"
sys.exit(0);
if __name__ == "__main__":
main()