forked from CMSCompOps/SiteReadiness
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ColumnInfo.py
90 lines (83 loc) · 3.71 KB
/
ColumnInfo.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import string
class ColumnInfo:
def __init__(self, options):
webserver="http://dashb-ssb.cern.ch" #"http://dashb-ssb-dev.cern.ch"
self.options = options
self.urls = {} # SSB URLs Matrix
self.criteria = {'T0':[],'T1':[],'T2':[],'T3':[]} # which columns to use for which tiers
self.colorCodes = {} # color codes
self.metorder = {} # metric order
self.metlegends = {} # metric legends
self.days = 0 # Number of days for which we'll retrieve information from SSB
self.daysSC = 0 # Number of previous days on which the current day's readiness depends
self.daysToShow = 0 # Number of days to show in html
self.colors = {}
self.creditTransfers = {} # method for transfering credit for metric values between sites (eg to account for disk/tape separation)
self.printCol = {} # metric print permission
metricCount = 1
tmpf = open(self.options.input + "/readiness.input")
for line in tmpf:
if line[0] == '#':
continue
words = line.split()
if line[0] == '^': # single parameters
words[0] = words[0].replace('^','')
if words[0] == 'days': self.days = int(words[1])
elif words[0] == 'daysSC': self.daysSC = int(words[1])
elif words[0] == 'daysToShow': self.daysToShow = int(words[1])
else:
print '\nERROR bad input file\n'
sys.exit()
continue
colName = words[0]
if self.days == 0 or self.daysSC == 0 or self.daysToShow == 0:
print 'ERROR need to set self.days in input'
sys.exit()
url = webserver + '/dashboard/request.py/getplotdata?columnid=' + words[1] + '&batch=1&time=' + str(self.days*24)
self.urls[colName] = url
# which columns for which tiers
tiers = words[2].split(',')
for tier in tiers:
if tier == '-':
continue
self.criteria[tier].append(colName)
# metric order
if words[3] != '-':
self.metorder[metricCount] = colName
metricCount += 1
# legend
self.metlegends[colName] = string.replace(words[3], '~', ' ')
# colors
self.colorCodes[colName] = {}
colors = words[4].split(',')
for pairStr in colors:
pair = pairStr.split(':')
if len(pair) != 2:
print 'ERROR! length not two'
sys.exit()
self.colorCodes[colName].update({pair[0]:pair[1]}) # {index:color}
# print permissions
pCol = words[5]
self.printCol[colName] = pCol
tmpf.close()
tmpf = open(self.options.input + "/colors.input")
for line in tmpf:
if line[0] == '#':
continue
words = line.split()
label = words[0]
if label == '_': # convention: underscore in input means a space
label = ' '
self.colors[label] = words[1]
tmpf.close()
tmpf = open(self.options.input + "/credit-transfers.input")
for line in tmpf:
if line[0] == '#':
continue
words = line.split()
receiver = words[0]
action = words[1]
giver = words[2]
metrics = words[3].split(',')
self.creditTransfers[receiver+'<---'+giver] = { action : metrics }
tmpf.close()