-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgetLogCollect.py
executable file
·53 lines (46 loc) · 1.64 KB
/
getLogCollect.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
53
#!/usr/bin/env python -u
import sys, os
import httplib, json
import pprint
from optparse import OptionParser
cmsweb_url = 'cmsweb.cern.ch'
def getWorkloadSummary(request):
"""
Receives the requestName as input and then fetch its workloadsummary
in couchdb. Returns a json object.
"""
conn = httplib.HTTPSConnection(cmsweb_url, \
cert_file = os.getenv('X509_USER_PROXY'), \
key_file = os.getenv('X509_USER_PROXY'))
r1 = conn.request('GET', '/couchdb/workloadsummary/' + request)
r2 = conn.getresponse()
data = r2.read()
s = json.loads(data)
conn.close()
return s
def main():
"""
Provided a request name, it will get the workloadSummary and then filter out
all the logCollect tarball paths. The output will be written to a file.
"""
usage = "Usage: %prog -r request"
parser = OptionParser(usage = usage)
parser.add_option('-r', '--request', help = 'Corresponds to the request name in ReqMgr', dest = 'request')
(options, args) = parser.parse_args()
if not options.request:
parser.error('You must provide a workflow name')
sys.exit(1)
reqout = getWorkloadSummary(options.request)
#pprint.pprint(reqout['logArchives'])
# will skip Merge logCollects
f = open('listOfLogCollets.txt', 'w')
for _, v in reqout['logArchives'].iteritems():
for tar in v:
if not 'outputMergeLogCollect' in tar:
print tar.split('SFN=')[1]
f.write(tar.split('SFN=')[1]+'\n')
print '\nList of tarballs saved in listOfLogCollets.txt'
f.close()
sys.exit(0)
if __name__ == "__main__":
main()