diff --git a/boswatch.py b/boswatch.py index 5242c5f..160b83e 100755 --- a/boswatch.py +++ b/boswatch.py @@ -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!") diff --git a/config/config.template.ini b/config/config.template.ini index 58f3f16..2512270 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -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] diff --git a/includes/globals.py b/includes/globals.py index 0e46a9a..68edb5c 100644 --- a/includes/globals.py +++ b/includes/globals.py @@ -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 = {} \ No newline at end of file diff --git a/includes/helper/wildcardHandler.py b/includes/helper/wildcardHandler.py index 10040d3..d3f85f2 100644 --- a/includes/helper/wildcardHandler.py +++ b/includes/helper/wildcardHandler.py @@ -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"]) diff --git a/includes/shellHeader.py b/includes/shellHeader.py index 28f8fd3..227346d 100644 --- a/includes/shellHeader.py +++ b/includes/shellHeader.py @@ -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 diff --git a/plugins/eMail/eMail.py b/plugins/eMail/eMail.py index 31f1902..aadab49 100644 --- a/plugins/eMail/eMail.py +++ b/plugins/eMail/eMail.py @@ -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)