added core config to jobs and tasks and made use of core variables raw in the tasks
This commit is contained in:
parent
16f51643f0
commit
06b933a135
5 changed files with 23 additions and 21 deletions
|
|
@ -17,10 +17,11 @@ class JabberTask(Task):
|
|||
self.set_task_type(kwargs["type"])
|
||||
self.recipient = kwargs["args"]["rcpt"]
|
||||
|
||||
def execute(self, msg):
|
||||
client = xmpp.Client('systemchaos.org')
|
||||
client.connect(server=('systemchaos.org', 5222))
|
||||
client.auth('linspector', 'PASSWORD', 'alert')
|
||||
def execute(self, msg, core):
|
||||
#TODO: totally unstable just to use values from core. make checks before...!
|
||||
client = xmpp.Client(core["tasks"]["jabber"]["host"])
|
||||
client.connect(server=(core["tasks"]["jabber"]["host"], core["tasks"]["jabber"]["port"]))
|
||||
client.auth(core["tasks"]["jabber"]["username"], core["tasks"]["jabber"]["password"], 'alert')
|
||||
client.sendInitPresence()
|
||||
message = xmpp.Message(self.recipient, msg)
|
||||
message.setAttr('type', 'chat')
|
||||
|
|
|
|||
|
|
@ -19,14 +19,14 @@ class MailTask(Task):
|
|||
self.set_task_type(kwargs["type"])
|
||||
self.recipient = kwargs["args"]["rcpt"]
|
||||
|
||||
def execute(self, msg):
|
||||
def execute(self, msg, core):
|
||||
message = MIMEText(msg)
|
||||
message['Subject'] = 'Warning from Linspector'
|
||||
message['Subject'] = msg
|
||||
now = datetime.datetime.now()
|
||||
message['Date'] = now.strftime("%a, %d %b %Y %H:%M:%S")
|
||||
message['From'] = "warning@linspector.org"
|
||||
message['From'] = core["tasks"]["mail"]["from"]
|
||||
message['To'] = self.recipient
|
||||
s = smtplib.SMTP('localhost')
|
||||
s = smtplib.SMTP(core["tasks"]["mail"]["host"], core["tasks"]["mail"]["port"])
|
||||
s.sendmail("warning@linspector.org", self.recipient, message.as_string())
|
||||
s.quit()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue