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.jobInfos[self.jobIndex] = jobInfo
|
||||
|
||||
|
||||
def handle_threshold(self, jobInfo, serviceThreshold, executionSucessful):
|
||||
if executionSucessful:
|
||||
if self.jobThreshold > 0:
|
||||
#TODO: maybe set threshold_handling for each service optionally; will override core setting!
|
||||
if self.core["threshold_handling"] == "reset":
|
||||
# Reset counter to 0
|
||||
self.log.debug("Threshold Reset")
|
||||
logger.debug("Threshold Reset")
|
||||
self.jobThreshold = 0
|
||||
else:
|
||||
# Decrement the counter (default)
|
||||
self.log.debug("Threshold Decrement")
|
||||
logger.debug("Threshold Decrement")
|
||||
self.jobThreshold -= 1
|
||||
else:
|
||||
self.jobThreshold += 1
|
||||
|
|
@ -102,7 +101,6 @@ class Job:
|
|||
for member in self.members:
|
||||
self.taskList.execute_task_infos(jobInfo.get_message(), member.get_tasks())
|
||||
|
||||
|
||||
def handle_call(self):
|
||||
logger.debug("handle call")
|
||||
logger.debug(self.service)
|
||||
|
|
|
|||
|
|
@ -54,15 +54,17 @@ class MailTask(Task):
|
|||
def execute(self, msg, taskArgs):
|
||||
if "recipient" not in taskArgs:
|
||||
raise "could not execute Mail Task! No recipient given!"
|
||||
|
||||
logger.debug("Eecuting Task!")
|
||||
|
||||
message = MIMEText(msg)
|
||||
message['Subject'] = msg
|
||||
now = datetime.datetime.now()
|
||||
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['To'] = taskArgs["recipient"]
|
||||
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.quit()
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ class TaskList(object):
|
|||
for taskInfo in taskInfos:
|
||||
task = self.find_task_by_name(taskInfo["class"])
|
||||
if task:
|
||||
logger.debug("Starting Task Execution...")
|
||||
task.execute(msg, taskInfo["args"])
|
||||
except:
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue