From 6b505b752c11997bec820991bd91fa993c003057 Mon Sep 17 00:00:00 2001 From: "Rafael.Timmerberg" Date: Thu, 20 Jun 2013 01:36:51 +0200 Subject: [PATCH] very very strange python, One day I'll pay you back! --- lib/config/hostgroups.py | 8 +++++--- linspector | 20 ++++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/config/hostgroups.py b/lib/config/hostgroups.py index 8719f88..1b3971e 100644 --- a/lib/config/hostgroups.py +++ b/lib/config/hostgroups.py @@ -11,7 +11,7 @@ class HostGroupMissingArgumentException(HostGroupException): super(HostGroupMissingArgumentException, self).__init__("no " + missingArgument + " defined for Hostgroup " + hostgroupName) -class HostGroup: +class HostGroup(object): def __init__(self, name, **kwargs): self.name = name tmp = "members" @@ -92,7 +92,9 @@ class HostGroup: return self.members def __str__(self): - ret = "HostGroup: " + self.name + " threshold: " + str(self.threshold) + " parent: " + self.parent + "\n" + if True: + return str(self.__dict__) + ret = "HostGroup: " + self.name + "\n" ret += "members: {\n" for itm in self.members: ret += str(itm) + "\n" @@ -102,7 +104,7 @@ class HostGroup: ret += str(itm) + "\n" ret += "}\n" ret += "services: {\n" - for itm in self.services: + for itm in self._services: ret += str(itm) + "\n" ret += "}\n" return ret diff --git a/linspector b/linspector index baf18bf..f50a168 100755 --- a/linspector +++ b/linspector @@ -62,16 +62,24 @@ def main(): jobs = [] for layout in layouts: - for i in range(len(layout.get_hostgroups())): - hg = layout.get_hostgroups()[i] - for serv in hg.get_services(): - for service in serv: - for period in service.get_periods(): - pass + #for i in range(len(layout._hostgroups)): + # for y in range(len(layout._hostgroups[i])._services): + # for period in layout.get_hostgroups()[i]._services[y]: + # log.i("wtf") + # for serv in layout.get_hostgroups()[i].get_services(): + # for service in serv: + # for period in service.get_periods(): + # pass if layout.is_enabled(): for hostgroup in layout.get_hostgroups(): for sr in hostgroup.get_services(): + if not isinstance(sr, list): + + log.i("check from hostgroup: id(" + str(id(hostgroup)) + ") " + str(hostgroup)) + log.i("check from sr.get_hostgroup(): id(" + str(id(sr.get_hostgroup)) + ") " + str(sr.get_hostgroup())) + sr = hostgroup.__dict__["_services"] + if not isinstance(sr, list): sr = sr.get_hostgroup().get_services() for s in sr: