many cleanups and new docs

This commit is contained in:
Johannes Findeisen 2013-05-27 03:54:04 +02:00
commit 51cbfff880
69 changed files with 261 additions and 239 deletions

View file

@ -34,4 +34,4 @@ class Config:
self.services,
log)
#self.layouts = LayoutList(self.dict['layouts'], self.hostgroups)
#self.layouts = LayoutList(self.dict['layouts'], self.hostgroups)

View file

@ -14,4 +14,4 @@ class Filter:
def parseFilterList(filters):
return [Filter(name, **values) for name, values in filters.items()]
return [Filter(name, **values) for name, values in filters.items()]

View file

@ -10,9 +10,9 @@ class Host:
self.comment = comment
def __str__(self):
ret = "Host('Name: " + self.name + "', 'access: " + self.host + "', "
ret = "Host('Name: " + self.name + "', 'Access: " + self.host + "', "
if self.parent != "":
ret += "'parent: " + self.parent + "', "
ret += "'Parent: " + self.parent + "', "
ret += "'HostServices: {"
for s in self.services:
ret += str(s) + "\n"

View file

@ -18,8 +18,8 @@ class Member:
class MemberFilter:
def __init__(self, filt, Value):
self.filt = filt
def __init__(self, filter, Value):
self.filter = filter
self.value = Value
def __str__(self):

View file

@ -1,6 +1,3 @@
from apscheduler.scheduler import Scheduler
class Period(object):
def __init__(self, name):
self.name = name
@ -13,8 +10,7 @@ class Period(object):
class IntervalPeriod(Period):
def __init__(self, name="", weeks=0,days=0, hours=0, minutes=0, seconds=0, start_date=None,
comment=None):
def __init__(self, name="", weeks=0, days=0, hours=0, minutes=0, seconds=0, start_date=None, comment=None):
super(IntervalPeriod, self).__init__(name)
self.days = days # number of days to wait
@ -26,18 +22,17 @@ class IntervalPeriod(Period):
self.comment = comment # comment
def createJob(self, scheduler, jobInfo, func):
return scheduler.add_interval_job(func, weeks=self.weeks, hours=self.hours, minutes=self.minutes, seconds=self.seconds, start_date=self.start_date, args=[jobInfo])
return scheduler.add_interval_job(func, weeks=self.weeks, hours=self.hours, minutes=self.minutes,
seconds=self.seconds, start_date=self.start_date, args=[jobInfo])
def __str__(self):
ret = "IntervalPeriod(Name: " + self.name + ")"
return ret
class CronPeriod(Period):
def __init__(self, name="", year="*", month="*", day="*", week="*",
day_of_week="*", hour="*", minute="*", second="0", start_date=None,
comment=None):
def __init__(self, name="", year="*", month="*", day="*", week="*", day_of_week="*", hour="*", minute="*",
second="0", start_date=None, comment=None):
super(CronPeriod, self).__init__(name)
self.year = year # 4-digit year number
self.month = month # month number (1-12)
@ -50,13 +45,14 @@ class CronPeriod(Period):
self.start_date = start_date
self.comment = comment
def __str__(self):
ret = "CronPeriod(Name: " + self.name + ")"
return ret
def createJob(self, scheduler, jobInfo, func):
return scheduler.add_cron_job(func, year=self.year, month=self.month, day=self.day, week=self.week, day_of_week=self.day_of_week, hour=self.hour, minute=self.minute, second=self.second,start_date=self.start_date, args=[jobInfo])
return scheduler.add_cron_job(func, year=self.year, month=self.month, day=self.day, week=self.week,
day_of_week=self.day_of_week, hour=self.hour, minute=self.minute,
second=self.second, start_date=self.start_date, args=[jobInfo])
class DatePeriod(Period):
@ -66,25 +62,22 @@ class DatePeriod(Period):
self.comment = comment
def __str__(self):
ret = "DatePeriod(Name: " + self.name + ","+ str(self.date) + ")"
ret = "DatePeriod(Name: " + self.name + ", " + str(self.date) + ")"
return ret
def createJob(self, scheduler, jobInfo, func):
return scheduler.add_date_job(func, self.date, [jobInfo])
def parsePeriodList(periodlist,log):
periods=[]
def parsePeriodList(periodlist, log):
periods = []
log.i(periodlist)
for name, values in periodlist.items():
if "date" in values:
periods.append(DatePeriod(name, **values))
continue
for i in [ "weeks","days", "hours", "minutes", "seconds", "start_date"]:
for i in ["weeks", "days", "hours", "minutes", "seconds", "start_date"]:
if i in values:
periods.append(IntervalPeriod(name, **values))
break
@ -94,9 +87,7 @@ def parsePeriodList(periodlist,log):
periods.append(CronPeriod(name, **values))
break
log.w("ignoring Period: " +str(name))
log.w("ignoring Period: " + str(name))
log.w("reason: could not determine PeriodType: " + str(values))
return periods
return periods

View file

@ -8,7 +8,7 @@ class Command:
self.error = ""
def __str__(self):
return command
return self.command
def hasProcessed(self):
return self.output != "" and self.error != ""
@ -25,4 +25,4 @@ class Command:
def getError(self):
if not self.hasProcessed():
self.doProcess()
return self.error
return self.error

View file

@ -20,8 +20,4 @@ class JobInfo:
self.log = log
def handleCall(self):
pass
pass

View file

@ -56,6 +56,4 @@ class Logger():
self.log.critical(message)
def close(self):
logging.shutdown()
logging.shutdown()