some cleanup

This commit is contained in:
Rafael.Timmerberg 2013-07-02 00:19:20 +02:00
commit 222af81bed
11 changed files with 13 additions and 157 deletions

View file

@ -1,6 +0,0 @@
from config import *
from core import *
from tasks import *
from parsers import *
from processors import *
from services import *

View file

@ -2,14 +2,12 @@ import re
class Member:
def __init__(self, nameid, name="", phone="", comment="", parent="", tasks=None):
self.id = nameid
def __init__(self, id, name="", comment="", tasks=None):
self.id = id
self.name = name
self.phone = phone
self.tasks = []
self.add_task(tasks)
self.comment = comment
self.parent = parent
def get_id(self):
return self.id

View file

@ -32,6 +32,7 @@ class JobInfo:
self.log.d("handle call")
self.log.d(self.service)
try:
self.service._execute()
except Exception, e:
self.log.d(e)

View file

@ -7,48 +7,15 @@ class Task:
"""
Base class for all built-in Tasks.
"""
def set_task_type(self, taskType):
"""
sets the type of this task.
Be aware! this method can only get called once!
:param taskType: the type of this task
"""
if hasattr(self, "_taskType"):
raise Exception("taskType is only allowed to set once!")
self.taskType = taskType
self._taskType = taskType
def get_task_type(self):
"""
:return: the type set by set_type_task
"""
return self._taskType
def execute_task(self, msg):
"""
this is the method tasks usually override.
It gets called anytime the task should get executed
default does nothing
:param msg: the msg for this task
"""
pass
def _execute(self, taskType, msg):
"""
internal method which gets called for any member in a hostgroup.
It determines if it has an appropriate type by comparing taskType with get_task_type().
Calls execute_task() if the type matches
:param taskType: the type of the fail which is compared with get_task_type()
:param msg: the error message
:return: True if execute_task() is called succesfully, else False
"""
if self.get_task_type() == taskType:
self.execute_task(msg)
return True
return False
def some_other_irrelevant_methods(self):
pass