use helper function curtime() and split date and time in eMail plugin

This commit is contained in:
Schrolli 2015-07-01 14:35:44 +02:00
parent 3b0a50f878
commit 29873c5ec3
2 changed files with 19 additions and 24 deletions

View file

@ -128,14 +128,14 @@ tablePOC = bos_pocsag
# %TSI% = Tactical Short Information (I-IV)
# %DESCR% = Description from csv-file
# %TIME% = Time (by script)
# %DATE% = DATE (by script)
# %DATE% = Date (by script)
#fms_url = www.google.de?code=%FMS%&stat=%STATUS%
fms_url =
# %ZVEI% = ZVEI 5-tone Code
# %DESCR% = Description from csv-file
# %TIME% = Time (by script)
# %DATE% = DATE (by script)
# %DATE% = Date (by script)
#zvei_url = www.google.de?zvei=%ZVEI%
zvei_url =
@ -146,7 +146,7 @@ zvei_url =
# %BITRATE% = Bitrate of the Pocsag telegram
# %DESCR% = Description from csv-file
# %TIME% = Time (by script)
# %DATE% = DATE (by script)
# %DATE% = Date (by script)
#poc_url = www.google.de?ric=%RIC%&subric=%FUNC%&msg=%MSG%
poc_url =
@ -177,15 +177,17 @@ priority = urgent
# %DIRT% = Direction of the telegram (Text-String)
# %TSI% = Tactical Short Information (I-IV)
# %DESCR% = Description from csv-file
# %TIME% = Date/Time (by script)
# %TIME% = Time (by script)
# %DATE% = Date (by script)
fms_subject = FMS: %FMS%
fms_message = %TIME%: %FMS% - Status: %STATUS% - Direction: %DIRT% - TSI: %TSI%
fms_message = %DATE% %TIME%: %FMS% - Status: %STATUS% - Direction: %DIRT% - TSI: %TSI%
# %ZVEI% = ZVEI 5-tone Code
# %DESCR% = Description from csv-file
# %TIME% = Date/Time (by script)
# %TIME% = Time (by script)
# %DATE% = Date (by script)
zvei_subject = Alarm: %ZVEI%
zvei_message = %TIME%: %ZVEI%
zvei_message = %DATE% %TIME%: %ZVEI%
# %RIC% = Pocsag RIC
# %FUNC% = Pocsac function/Subric (1-4)
@ -193,9 +195,10 @@ zvei_message = %TIME%: %ZVEI%
# %MSG% = Message of the Pocsag telegram
# %BITRATE% = Bitrate of the Pocsag telegram
# %DESCR% = Description from csv-file
# %TIME% = Date/Time (by script)
# %TIME% = Time (by script)
# %DATE% = Date (by script)
poc_subject = Alarm: %RIC%%FUNCCHAR%
poc_message = %TIME%: %MSG%
poc_message = %DATE% %TIME%: %MSG%
[BosMon]

View file

@ -18,6 +18,7 @@ from email.utils import formatdate # need for confirm to RFC2822 standard
from email.utils import make_msgid # need for confirm to RFC2822 standard
from includes import globals # Global variables
from includes import helper #Global helper functions
##
#
@ -35,16 +36,7 @@ def onLoad():
"""
# nothing to do for this plugin
return
##
#
# Private helper function for a printable Timestamp
#
def curtime():
return time.strftime("%Y-%m-%d %H:%M:%S")
##
#
# do send mail
@ -149,14 +141,14 @@ def run(typ,freq,data):
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%", curtime()) # replace Wildcards
subject = subject.replace("%TIME%", helper.curtime("H:M:S")).replace("%DATE%", helper.curtime("Y-m-d")) # replace Wildcards
# 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%", curtime()) # replace Wildcards
mailtext = mailtext.replace("%TIME%", helper.curtime("H:M:S")).replace("%DATE%", helper.curtime("Y-m-d")) # replace Wildcards
# send eMail
doSendmail(server, subject, mailtext)
except:
@ -171,12 +163,12 @@ def run(typ,freq,data):
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%", curtime()) # replace Wildcards
subject = subject.replace("%TIME%", helper.curtime("H:M:S")).replace("%DATE%", helper.curtime("Y-m-d")) # replace Wildcards
# 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%", curtime()) # replace Wildcards
mailtext = mailtext.replace("%TIME%", helper.curtime("H:M:S")).replace("%DATE%", helper.curtime("Y-m-d")) # replace Wildcards
# send eMail
doSendmail(server, subject, mailtext)
except:
@ -193,14 +185,14 @@ def run(typ,freq,data):
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%", curtime()) # replace Wildcards
subject = subject.replace("%TIME%", helper.curtime("H:M:S")).replace("%DATE%", helper.curtime("Y-m-d")) # replace Wildcards
# 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%", curtime()) # replace Wildcards
mailtext = mailtext.replace("%TIME%", helper.curtime("H:M:S")).replace("%DATE%", helper.curtime("Y-m-d")) # replace Wildcards
# send eMail
doSendmail(server, subject, mailtext)
except: