whitespacing.... :)
This commit is contained in:
parent
2c40772796
commit
883e59a3d1
22 changed files with 66 additions and 109 deletions
|
|
@ -4,6 +4,7 @@ The email task.
|
|||
|
||||
from lib.tasks.task import Task
|
||||
|
||||
|
||||
class EmailTask(Task):
|
||||
def __init__(self, **kwargs):
|
||||
if not "type" in kwargs:
|
||||
|
|
@ -12,13 +13,10 @@ class EmailTask(Task):
|
|||
raise Exception("typeDict " + str(kwargs) + " has nor arguments!")
|
||||
self.set_task_type(kwargs["type"])
|
||||
self.recipient = kwargs["args"]["rcpt"]
|
||||
|
||||
|
||||
|
||||
def execute_task(self, msg):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def creator(**taskDict):
|
||||
return EmailTask(**taskDict)
|
||||
|
|
@ -4,6 +4,7 @@ The sms task.
|
|||
|
||||
from task import Task
|
||||
|
||||
|
||||
class SmsTask(Task):
|
||||
def __init__(self, **kwargs):
|
||||
if not "type" in kwargs:
|
||||
|
|
@ -12,13 +13,10 @@ class SmsTask(Task):
|
|||
raise Exception("typeDict " + str(kwargs) + " has no arguments!")
|
||||
self.set_task_type(kwargs["type"])
|
||||
self.recipient = kwargs["args"]["rcpt"]
|
||||
|
||||
|
||||
|
||||
def execute_task(self, msg):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def creator(**taskDict):
|
||||
return SmsTask(**taskDict)
|
||||
return SmsTask(**taskDict)
|
||||
|
|
@ -1,35 +1,36 @@
|
|||
'''
|
||||
"""
|
||||
Created on Jun 15, 2013
|
||||
|
||||
@author: Rafael Timmerberg
|
||||
'''
|
||||
"""
|
||||
|
||||
|
||||
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!
|
||||
|
||||
params:
|
||||
taskType: the type of this task
|
||||
'''
|
||||
"""
|
||||
if hasattr(self, "_taskType"):
|
||||
raise Exception("taskType is only allowed to set once!")
|
||||
self.taskType = taskType
|
||||
|
||||
def get_task_type(self):
|
||||
'''
|
||||
"""
|
||||
returns 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
|
||||
|
||||
|
|
@ -37,11 +38,11 @@ class Task:
|
|||
|
||||
params:
|
||||
msg: the msg for this task
|
||||
'''
|
||||
"""
|
||||
pass
|
||||
|
||||
def _execute(self,taskType, msg):
|
||||
'''
|
||||
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
|
||||
|
|
@ -52,9 +53,8 @@ class Task:
|
|||
|
||||
return:
|
||||
True if execute_task() is called succesfully, else False
|
||||
'''
|
||||
"""
|
||||
if self.get_task_type() == taskType:
|
||||
self.execute_task(msg)
|
||||
return True
|
||||
return False
|
||||
|
||||
return False
|
||||
|
|
@ -4,6 +4,7 @@ The xmpp task.
|
|||
|
||||
from task import Task
|
||||
|
||||
|
||||
class XmppTask(Task):
|
||||
def __init__(self, **kwargs):
|
||||
if not "type" in kwargs:
|
||||
|
|
@ -12,13 +13,10 @@ class XmppTask(Task):
|
|||
raise Exception("typeDict " + str(kwargs) + " has nor arguments!")
|
||||
self.set_task_type(kwargs["type"])
|
||||
self.recipient = kwargs["args"]["rcpt"]
|
||||
|
||||
|
||||
|
||||
def execute_task(self, msg):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def creator(**taskDict):
|
||||
return XmppTask(taskDict)
|
||||
Loading…
Add table
Add a link
Reference in a new issue