add line break to eMail plugin #71

This commit is contained in:
JHCD 2015-07-28 19:44:14 +02:00
parent f95a270177
commit 19653e5515
6 changed files with 53 additions and 39 deletions

View file

@ -153,8 +153,8 @@ try:
# For debug display/log args
#
try:
logging.debug("SW Version: %s",globals.getVers("vers"))
logging.debug("Build Date: %s",globals.getVers("date"))
logging.debug("SW Version: %s",globals.versionNr)
logging.debug("Build Date: %s",globals.buildDate)
logging.debug("BOSWatch given arguments")
if args.test:
logging.debug(" - Test-Mode!")

View file

@ -189,34 +189,43 @@ to = user@irgendwo, user2@woanders
# normal|urgent|non-urgent
priority = urgent
# %FMS% = FMS Code
# %STATUS% = FMS Status
# %DIR% = Direction of the telegram (0/1)
# %DIRT% = Direction of the telegram (Text-String)
# %TSI% = Tactical Short Information (I-IV)
# %DESCR% = Description from csv-file
# %TIME% = Time (by script)
# %DATE% = Date (by script)
# %FMS% = FMS Code
# %STATUS% = FMS Status
# %DIR% = Direction of the telegram (0/1)
# %DIRT% = Direction of the telegram (Text-String)
# %TSI% = Tactical Short Information (I-IV)
# %DESCR% = Description, if description-module is used
# %DATE% = Date (by script)
# %TIME% = Time (by script)
# %BR% = Insert line wrap (only in message)
# %LPAR% = (
# %RPAR% = )
fms_subject = FMS: %FMS%
fms_message = %DATE% %TIME%: %FMS% - Status: %STATUS% - Direction: %DIRT% - TSI: %TSI%
fms_message = %DATE% %TIME%: %FMS%%BR%Status: %STATUS% - Direction: %DIRT% - TSI: %TSI%
# %ZVEI% = ZVEI 5-tone Code
# %DESCR% = Description from csv-file
# %TIME% = Time (by script)
# %DATE% = Date (by script)
# %ZVEI% = ZVEI 5-tone Code
# %DESCR% = Description, if description-module is used
# %DATE% = Date (by script)
# %TIME% = Time (by script)
# %BR% = Insert line wrap (only in message)
# %LPAR% = (
# %RPAR% = )
zvei_subject = Alarm: %ZVEI%
zvei_message = %DATE% %TIME%: %ZVEI%
# %RIC% = Pocsag RIC
# %FUNC% = Pocsac function/Subric (1-4)
# %RIC% = Pocsag RIC
# %FUNC% = Pocsac function/Subric (1-4)
# %FUNCCHAR% = Pocsac function/Subric als character (a-d)
# %MSG% = Message of the Pocsag telegram
# %BITRATE% = Bitrate of the Pocsag telegram
# %DESCR% = Description from csv-file
# %TIME% = Time (by script)
# %DATE% = Date (by script)
poc_subject = Alarm: %RIC%%FUNCCHAR%
poc_message = %DATE% %TIME%: %MSG%
# %MSG% = Message of the Pocsag telegram
# %BITRATE% = Bitrate of the Pocsag telegram
# %DESCR% = Description, if description-module is used
# %DATE% = Date (by script)
# %TIME% = Time (by script)
# %BR% = Insert line wrap (only in message)
# %LPAR% = (
# %RPAR% = )
poc_subject = Alarm: %RIC%%LPAR%%FUNCCHAR%%RPAR%
poc_message = %DATE% %TIME% - %DESCR%: %MSG%
[BosMon]

View file

@ -8,6 +8,10 @@ Global variables
@author: Bastian Schroll
"""
# version info
versionNr = "2.1-dev"
buildDate = "2015/07/28"
# Global variables
config = 0
script_path = ""
@ -25,12 +29,4 @@ filterList = []
# idDescribing
fmsDescribtionList = {}
zveiDescribtionList = {}
ricDescribtionList = {}
# returns the version or build date
# function -> read only in script
def getVers(mode="vers"):
if mode == "vers":
return "2.1-dev"
elif mode == "date":
return "2015/07/27"
ricDescribtionList = {}

View file

@ -7,6 +7,7 @@ little Helper to replace fast and easy the standard wildcards
for direct use in plugins to save code
@author: Bastian Schroll
@author: Jens Herrmann
"""
import logging
@ -14,7 +15,7 @@ import logging
from includes.helper import timeHandler
def replaceWildcards(text,data):
def replaceWildcards(text, data, lineBrakeAllowed=False):
"""
Replace all official Wildcards with the Information from the data[] var
@ -22,6 +23,8 @@ def replaceWildcards(text,data):
@param text: Input text with wildcards
@type data: map
@param data: map of data (structure see interface.txt)
@type lineBrakeAllowed: Boolean
@param lineBrakeAllowed: switch to allow lineBreak (%BR%) as wildcard
@return: text with replaced wildcards
@exception: Exception if Error at replace
@ -29,6 +32,12 @@ def replaceWildcards(text,data):
try:
# replace date and time wildcards
text = text.replace("%TIME%", timeHandler.getTime()).replace("%DATE%", timeHandler.getDate())
# replace some special chars
if lineBrakeAllowed == True:
text = text.replace("%BR%", "\r\n")
text = text.replace("%LPAR%", "(")
text = text.replace("%RPAR%", ")")
# replace FMS data
if "fms" in data: text = text.replace("%FMS%", data["fms"])

View file

@ -30,8 +30,8 @@ def printHeader(args):
print " German BOS Information Script "
print " by Bastian Schroll, Jens Herrmann "
print ""
print "SW Version: "+globals.getVers("vers")
print "Build Date: "+globals.getVers("date")
print "SW Version: "+globals.versionNr
print "Build Date: "+globals.buildDate
print ""
print "Frequency: "+args.freq

View file

@ -135,7 +135,7 @@ def run(typ,freq,data):
# read mailtext-structure from config.ini
mailtext = globals.config.get("eMail", "fms_message")
# replace wildcards with helper function
mailtext = wildcardHandler.replaceWildcards(mailtext, data)
mailtext = wildcardHandler.replaceWildcards(mailtext, data, lineBrakeAllowed=True)
# send eMail
doSendmail(server, subject, mailtext)
@ -155,7 +155,7 @@ def run(typ,freq,data):
# read mailtext-structure from config.ini
mailtext = globals.config.get("eMail", "zvei_message")
# replace wildcards with helper function
mailtext = wildcardHandler.replaceWildcards(mailtext, data)
mailtext = wildcardHandler.replaceWildcards(mailtext, data, lineBrakeAllowed=True)
# send eMail
doSendmail(server, subject, mailtext)
@ -175,7 +175,7 @@ def run(typ,freq,data):
# read mailtext-structure from config.ini
mailtext = globals.config.get("eMail", "poc_message")
# replace wildcards with helper function
mailtext = wildcardHandler.replaceWildcards(mailtext, data)
mailtext = wildcardHandler.replaceWildcards(mailtext, data, lineBrakeAllowed=True)
# send eMail
doSendmail(server, subject, mailtext)