lot of small fixes, typo etc. and some more logging in tasks
This commit is contained in:
parent
8b435ca55d
commit
1f52f2c931
3 changed files with 7 additions and 6 deletions
|
|
@ -78,18 +78,17 @@ class Job:
|
||||||
self.jobIndex = 0
|
self.jobIndex = 0
|
||||||
self.jobInfos[self.jobIndex] = jobInfo
|
self.jobInfos[self.jobIndex] = jobInfo
|
||||||
|
|
||||||
|
|
||||||
def handle_threshold(self, jobInfo, serviceThreshold, executionSucessful):
|
def handle_threshold(self, jobInfo, serviceThreshold, executionSucessful):
|
||||||
if executionSucessful:
|
if executionSucessful:
|
||||||
if self.jobThreshold > 0:
|
if self.jobThreshold > 0:
|
||||||
#TODO: maybe set threshold_handling for each service optionally; will override core setting!
|
#TODO: maybe set threshold_handling for each service optionally; will override core setting!
|
||||||
if self.core["threshold_handling"] == "reset":
|
if self.core["threshold_handling"] == "reset":
|
||||||
# Reset counter to 0
|
# Reset counter to 0
|
||||||
self.log.debug("Threshold Reset")
|
logger.debug("Threshold Reset")
|
||||||
self.jobThreshold = 0
|
self.jobThreshold = 0
|
||||||
else:
|
else:
|
||||||
# Decrement the counter (default)
|
# Decrement the counter (default)
|
||||||
self.log.debug("Threshold Decrement")
|
logger.debug("Threshold Decrement")
|
||||||
self.jobThreshold -= 1
|
self.jobThreshold -= 1
|
||||||
else:
|
else:
|
||||||
self.jobThreshold += 1
|
self.jobThreshold += 1
|
||||||
|
|
@ -102,7 +101,6 @@ class Job:
|
||||||
for member in self.members:
|
for member in self.members:
|
||||||
self.taskList.execute_task_infos(jobInfo.get_message(), member.get_tasks())
|
self.taskList.execute_task_infos(jobInfo.get_message(), member.get_tasks())
|
||||||
|
|
||||||
|
|
||||||
def handle_call(self):
|
def handle_call(self):
|
||||||
logger.debug("handle call")
|
logger.debug("handle call")
|
||||||
logger.debug(self.service)
|
logger.debug(self.service)
|
||||||
|
|
|
||||||
|
|
@ -54,15 +54,17 @@ class MailTask(Task):
|
||||||
def execute(self, msg, taskArgs):
|
def execute(self, msg, taskArgs):
|
||||||
if "recipient" not in taskArgs:
|
if "recipient" not in taskArgs:
|
||||||
raise "could not execute Mail Task! No recipient given!"
|
raise "could not execute Mail Task! No recipient given!"
|
||||||
|
|
||||||
|
logger.debug("Eecuting Task!")
|
||||||
|
|
||||||
message = MIMEText(msg)
|
message = MIMEText(msg)
|
||||||
message['Subject'] = msg
|
message['Subject'] = msg
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
message['Date'] = now.strftime("%a, %d %b %Y %H:%M:%S")
|
message['Date'] = now.strftime("%a, %d %b %Y %H:%M:%S")
|
||||||
#TODO: totally unstable just to use values from core. make checks before...!
|
|
||||||
message['From'] = self.fromName
|
message['From'] = self.fromName
|
||||||
message['To'] = taskArgs["recipient"]
|
message['To'] = taskArgs["recipient"]
|
||||||
s = smtplib.SMTP(self.host, self.port)
|
s = smtplib.SMTP(self.host, self.port)
|
||||||
s.login(self.userName, self.password)
|
#s.login(self.userName, self.password)
|
||||||
s.sendmail(self.fromName, taskArgs["recipient"], message.as_string())
|
s.sendmail(self.fromName, taskArgs["recipient"], message.as_string())
|
||||||
s.quit()
|
s.quit()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ class TaskList(object):
|
||||||
for taskInfo in taskInfos:
|
for taskInfo in taskInfos:
|
||||||
task = self.find_task_by_name(taskInfo["class"])
|
task = self.find_task_by_name(taskInfo["class"])
|
||||||
if task:
|
if task:
|
||||||
|
logger.debug("Starting Task Execution...")
|
||||||
task.execute(msg, taskInfo["args"])
|
task.execute(msg, taskInfo["args"])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue