housekeeping and cleanups...

This commit is contained in:
Johannes Findeisen 2013-05-30 04:20:35 +02:00
commit 63c4b4aa98
5 changed files with 23 additions and 33 deletions

View file

@ -45,12 +45,12 @@ class HostService:
ret += "warning: " + str(self.warning) ret += "warning: " + str(self.warning)
if self.critical: if self.critical:
ret += "critical: " + str(self.critical) ret += "critical: " + str(self.critical)
return ret; return ret
def parseHostList(hosts, services, log): def parseHostList(hosts, services, log):
""" """
parse the HostList and replace any command as nessesary parse the HostList and replace any command as necessary
""" """
#precompiled regexPattern which finds replacements in service strings #precompiled regexPattern which finds replacements in service strings
pattern = re.compile("@(\w+)") pattern = re.compile("@(\w+)")

View file

@ -16,13 +16,13 @@ class Command:
return self.command return self.command
def call(self): def call(self):
'''
self.commandStart = dt.now() # self.commandStart = dt.now()
"called at: " # "called at: "
process = sp.Popen(stdout=PIPE, *popenargs, **kwargs) # process = sp.Popen(stdout=PIPE, *popenargs, **kwargs)
self.output, self.error = process.communicate() # self.output, self.error = process.communicate()
self.retcode = process.poll() # self.retcode = process.poll()
'''
try: try:
self.commandStart = dt.now() self.commandStart = dt.now()
self.log.i("calling command " + str(self.command) + " at " + str(self.commandStart)) self.log.i("calling command " + str(self.command) + " at " + str(self.commandStart))
@ -36,7 +36,6 @@ class Command:
self.error = CalledProcessError.output self.error = CalledProcessError.output
self.retcode = CalledProcessError.returncode self.retcode = CalledProcessError.returncode
def getOutput(self): def getOutput(self):
return self.output return self.output
@ -48,4 +47,3 @@ class Command:
def getReturnCode(self): def getReturnCode(self):
return self.retcode return self.retcode

View file

@ -5,12 +5,14 @@ execute.
from command import Command from command import Command
def generateId(): def generateId():
i = 0 i = 0
while True: while True:
yield i yield i
i += 1 i += 1
class JobInfo: class JobInfo:
def __init__(self, hostgroupname, members, hosts, hostServices, threshold, parent=None): def __init__(self, hostgroupname, members, hosts, hostServices, threshold, parent=None):
self.members = members self.members = members
@ -51,13 +53,3 @@ class JobInfo:
self.log.d(cmd.getAllOutput()) self.log.d(cmd.getAllOutput())
except Exception: except Exception:
self.log.d(Exception) self.log.d(Exception)
#must find real service command stored in hosts...
#but because of error, mentioned in NOTES,ruff, there is no ping i.e.
#cmd = Command(service.command)
#self.log.d("executing command: " + str(command))
#cmd.call()
#return cmd