forked from CMSCompOps/WmAgentScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnnounceWF.py
executable file
·33 lines (27 loc) · 1.1 KB
/
AnnounceWF.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
#!/usr/bin/env python
import urllib2,urllib, httplib, sys, re, os, json, phedexSubscription
from xml.dom.minidom import getDOMImplementation
def AnnounceWorkflow(url, workflowname):
conn = httplib.HTTPSConnection(url, cert_file = os.getenv('X509_USER_PROXY'), key_file = os.getenv('X509_USER_PROXY'))
params = {"requestName" : workflowname, "cascade" : True}
headers={"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"}
encodedParams = urllib.urlencode(params)
conn.request("POST", "/reqmgr/reqMgr/announce", encodedParams, headers)
response = conn.getresponse()
data = response.read()
conn.close()
def main():
args=sys.argv[1:]
if not len(args)==1:
print "usage:AnnounceWF.py file name"
print "where the file should contain a list of workflows"
sys.exit(0)
filename=args[0]
url='cmsweb.cern.ch'
workflows=phedexSubscription.workflownamesfromFile(filename)
for workflow in workflows:
AnnounceWorkflow(url, workflow)
print workflow+" announced"
sys.exit(0);
if __name__ == "__main__":
main()