1 |
import apmon
|
2 |
|
3 |
class ApmonIf:
|
4 |
"""
|
5 |
Provides an interface to the Monalisa Apmon python module
|
6 |
"""
|
7 |
def __init__(self, address='http://lxgate35.cern.ch:40808/ApMonConf'):
|
8 |
self._params = {}
|
9 |
self.fName = 'mlCommonInfo'
|
10 |
self._MLaddress = address
|
11 |
self.apm = None
|
12 |
self.apm = self.getApmonInstance()
|
13 |
|
14 |
def fillDict(self, parr):
|
15 |
"""
|
16 |
Used to fill the dictionary of key/value pair and instantiate the ML client
|
17 |
"""
|
18 |
self._params = parr
|
19 |
|
20 |
def sendToML(self):
|
21 |
self.apm.sendParameters(self._params['taskId'], self._params['jobId'], self._params)
|
22 |
|
23 |
def getApmonInstance(self):
|
24 |
if self.apm is None :
|
25 |
try:
|
26 |
apmonUrl = 'http://lxgate35.cern.ch:40808/ApMonConf'
|
27 |
print "Creating ApMon with " + apmonUrl
|
28 |
apmonInstance = apmon.ApMon(apmonUrl, apmon.Logger.WARNING)
|
29 |
except:
|
30 |
print "PIPPO"
|
31 |
return apmonInstance
|
32 |
|
33 |
def free(self):
|
34 |
self.apm.free()
|