mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-01-20 23:30:17 +01:00
change replace wildcards to helper-function
This commit is contained in:
parent
65a35d4a64
commit
6520edea4c
|
|
@ -20,7 +20,8 @@ from email.utils import make_msgid # need for confirm to RFC2822 standard
|
|||
from includes import globals # Global variables
|
||||
|
||||
from includes.helper import timeHandler # helper function
|
||||
from includes.helper import configHandler
|
||||
from includes.helper import configHandler # helper function
|
||||
from includes.helper import wildcardHandler # helper function
|
||||
|
||||
##
|
||||
#
|
||||
|
|
@ -100,7 +101,7 @@ def run(typ,freq,data):
|
|||
if configHandler.checkConfig("eMail"): #read and debug the config
|
||||
|
||||
try:
|
||||
#
|
||||
#
|
||||
# connect to SMTP-Server
|
||||
#
|
||||
server = smtplib.SMTP(globals.config.get("eMail", "smtp_server"), globals.config.get("eMail", "smtp_port"))
|
||||
|
|
@ -128,18 +129,14 @@ def run(typ,freq,data):
|
|||
try:
|
||||
# read subject-structure from config.ini
|
||||
subject = globals.config.get("eMail", "fms_subject")
|
||||
subject = subject.replace("%FMS%", data["fms"]).replace("%STATUS%", data["status"]) #replace Wildcards
|
||||
subject = subject.replace("%DIR%", data["direction"]).replace("%DIRT%", data["directionText"]) #replace Wildcards
|
||||
subject = subject.replace("%TSI%", data["tsi"]) #replace Wildcards
|
||||
subject = subject.replace("%DESCR%", data["description"]) # replace Wildcards
|
||||
subject = subject.replace("%TIME%", timeHandler.getTime()).replace("%DATE%", timeHandler.curtime("%Y-%m-%d")) # replace Wildcards
|
||||
# replace wildcards with helper function
|
||||
subject = wildcardHandler.replaceWildcards(subject, data)
|
||||
|
||||
# read mailtext-structure from config.ini
|
||||
mailtext = globals.config.get("eMail", "fms_message")
|
||||
mailtext = mailtext.replace("%FMS%", data["fms"]).replace("%STATUS%", data["status"]) #replace Wildcards
|
||||
mailtext = mailtext.replace("%DIR%", data["direction"]).replace("%DIRT%", data["directionText"]) #replace Wildcards
|
||||
mailtext = mailtext.replace("%TSI%", data["tsi"]) #replace Wildcards
|
||||
mailtext = mailtext.replace("%DESCR%", data["description"]) # replace Wildcards
|
||||
mailtext = mailtext.replace("%TIME%", timeHandler.getTime()).replace("%DATE%", timeHandler.curtime("%Y-%m-%d")) # replace Wildcards
|
||||
# replace wildcards with helper function
|
||||
mailtext = wildcardHandler.replaceWildcards(mailtext, data)
|
||||
|
||||
# send eMail
|
||||
doSendmail(server, subject, mailtext)
|
||||
except:
|
||||
|
|
@ -152,14 +149,14 @@ def run(typ,freq,data):
|
|||
try:
|
||||
# read subject-structure from config.ini
|
||||
subject = globals.config.get("eMail", "zvei_subject")
|
||||
subject = subject.replace("%ZVEI%", data["zvei"]) #replace Wildcards
|
||||
subject = subject.replace("%DESCR%", data["description"]) # replace Wildcards
|
||||
subject = subject.replace("%TIME%", timeHandler.getTime()).replace("%DATE%", timeHandler.curtime("%Y-%m-%d")) # replace Wildcards
|
||||
# replace wildcards with helper function
|
||||
subject = wildcardHandler.replaceWildcards(subject, data)
|
||||
|
||||
# read mailtext-structure from config.ini
|
||||
mailtext = globals.config.get("eMail", "zvei_message")
|
||||
mailtext = mailtext.replace("%ZVEI%", data["zvei"]) #replace Wildcards
|
||||
mailtext = mailtext.replace("%DESCR%", data["description"]) # replace Wildcards
|
||||
mailtext = mailtext.replace("%TIME%", timeHandler.getTime()).replace("%DATE%", timeHandler.curtime("%Y-%m-%d")) # replace Wildcards
|
||||
# replace wildcards with helper function
|
||||
mailtext = wildcardHandler.replaceWildcards(mailtext, data)
|
||||
|
||||
# send eMail
|
||||
doSendmail(server, subject, mailtext)
|
||||
except:
|
||||
|
|
@ -172,18 +169,14 @@ def run(typ,freq,data):
|
|||
try:
|
||||
# read subject-structure from config.ini
|
||||
subject = globals.config.get("eMail", "poc_subject")
|
||||
subject = subject.replace("%RIC%", data["ric"]) #replace Wildcards
|
||||
subject = subject.replace("%FUNC%", data["function"]).replace("%FUNCCHAR%", data["functionChar"]) #replace Wildcards
|
||||
subject = subject.replace("%MSG%", data["msg"]).replace("%BITRATE%", str(data["bitrate"])) #replace Wildcards
|
||||
subject = subject.replace("%DESCR%", data["description"]) # replace Wildcards
|
||||
subject = subject.replace("%TIME%", timeHandler.getTime()).replace("%DATE%", timeHandler.curtime("%Y-%m-%d")) # replace Wildcards
|
||||
# replace wildcards with helper function
|
||||
subject = wildcardHandler.replaceWildcards(subject, data)
|
||||
|
||||
# read mailtext-structure from config.ini
|
||||
mailtext = globals.config.get("eMail", "poc_message")
|
||||
mailtext = mailtext.replace("%RIC%", data["ric"]) #replace Wildcards
|
||||
mailtext = mailtext.replace("%FUNC%", data["function"]).replace("%FUNCCHAR%", data["functionChar"]) #replace Wildcards
|
||||
mailtext = mailtext.replace("%MSG%", data["msg"]).replace("%BITRATE%", str(data["bitrate"])) #replace Wildcards
|
||||
mailtext = mailtext.replace("%DESCR%", data["description"]) # replace Wildcards
|
||||
mailtext = mailtext.replace("%TIME%", timeHandler.getTime()).replace("%DATE%", timeHandler.curtime("%Y-%m-%d")) # replace Wildcards
|
||||
# replace wildcards with helper function
|
||||
mailtext = wildcardHandler.replaceWildcards(mailtext, data)
|
||||
|
||||
# send eMail
|
||||
doSendmail(server, subject, mailtext)
|
||||
except:
|
||||
|
|
|
|||
Loading…
Reference in a new issue