From d6ce41f42be56013fca62e03480a4a2f3fb3c37a Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Thu, 30 Mar 2017 21:37:50 +0200 Subject: [PATCH 01/32] edit vers nr --- includes/globalVars.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/globalVars.py b/includes/globalVars.py index bd0cd55..2cdcfa7 100644 --- a/includes/globalVars.py +++ b/includes/globalVars.py @@ -9,8 +9,8 @@ Global variables """ # version info -versionNr = "2.2-beta" -buildDate = "2016/02/23" +versionNr = "2.2-dev" +buildDate = "2017/03/30" # Global variables config = 0 From 97f2956bc3f4bcd4bfe3bbd4e1c6cd510336194b Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 4 Apr 2017 22:14:26 +0200 Subject: [PATCH 02/32] Switching mm_raw to off by default As it's mainly for debug-reasons, there is no need to enable the mm_raw-out by default. --- config/config.template.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.template.ini b/config/config.template.ini index be5484b..6f7f018 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -49,7 +49,7 @@ doubleFilter_ignore_time = 5 doubleFilter_check_msg = 0 # writes the multimon-ng raw data stream into a text file named mm_raw.txt -writeMultimonRaw = 1 +writeMultimonRaw = 0 [NMAHandler] # you can use a logging handler for sending logging records to NotifyMyAndroid From 7abda0bc509a86fee974aff50275325dcb099187 Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 4 Apr 2017 22:16:28 +0200 Subject: [PATCH 03/32] Delete events Delete events from default-installation and extract them to a separate file --- plugins/MySQL/boswatch.sql | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/plugins/MySQL/boswatch.sql b/plugins/MySQL/boswatch.sql index 8a88c68..6f93861 100644 --- a/plugins/MySQL/boswatch.sql +++ b/plugins/MySQL/boswatch.sql @@ -104,44 +104,6 @@ CREATE TABLE IF NOT EXISTS `bos_signal` ( PRIMARY KEY (`ID`) ) ENGINE=MYISAM DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1; --- -------------------------------------------------------- - --- --- Schedule für Tabelle `bos_pocsag` --- -CREATE EVENT IF NOT EXISTS `Delete POCSAG Entries > 3 Months` - ON SCHEDULE EVERY 1 DAY - STARTS '2016-01-01 00:00:00' - ON COMPLETION PRESERVE ENABLE - DO - DELETE FROM bos_pocsag WHERE time < DATE_SUB(NOW(),INTERVAL 3 MONTH); - --- -------------------------------------------------------- - --- --- Schedule für Tabelle `bos_fms` --- - -CREATE EVENT IF NOT EXISTS `Delete FMS Entries > 3 Months` - ON SCHEDULE EVERY 1 DAY - STARTS '2016-01-01 00:00:00' - ON COMPLETION PRESERVE ENABLE - DO - DELETE FROM bos_fms WHERE time < DATE_SUB(NOW(),INTERVAL 3 MONTH); - --- -------------------------------------------------------- - --- --- Schedule für Tabelle `bos_zvei` --- - -CREATE EVENT IF NOT EXISTS `Delete ZVEI Entries > 3 Months` - ON SCHEDULE EVERY 1 DAY - STARTS '2016-01-01 00:00:00' - ON COMPLETION PRESERVE ENABLE - DO - DELETE FROM bos_zvei WHERE time < DATE_SUB(NOW(),INTERVAL 3 MONTH); - /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; From 7d7c33e2083a8d635606172125e12cbff546ad5b Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 4 Apr 2017 22:17:54 +0200 Subject: [PATCH 04/32] Create boswatch_cleanup.sql Extracted routines to cleanup old database-entries. --- plugins/MySQL/boswatch_cleanup.sql | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 plugins/MySQL/boswatch_cleanup.sql diff --git a/plugins/MySQL/boswatch_cleanup.sql b/plugins/MySQL/boswatch_cleanup.sql new file mode 100644 index 0000000..eb3fcb0 --- /dev/null +++ b/plugins/MySQL/boswatch_cleanup.sql @@ -0,0 +1,40 @@ +-- Cleanup-routines for boswatch-tables + +use boswatch; +-- -------------------------------------------------------- + +-- +-- Schedule für Tabelle `bos_pocsag` +-- +CREATE EVENT IF NOT EXISTS `Delete POCSAG Entries > 3 Months` + ON SCHEDULE EVERY 1 DAY + STARTS '2016-01-01 00:00:00' + ON COMPLETION PRESERVE ENABLE + DO + DELETE FROM bos_pocsag WHERE time < DATE_SUB(NOW(),INTERVAL 3 MONTH); + +-- -------------------------------------------------------- + +-- +-- Schedule für Tabelle `bos_fms` +-- + +CREATE EVENT IF NOT EXISTS `Delete FMS Entries > 3 Months` + ON SCHEDULE EVERY 1 DAY + STARTS '2016-01-01 00:00:00' + ON COMPLETION PRESERVE ENABLE + DO + DELETE FROM bos_fms WHERE time < DATE_SUB(NOW(),INTERVAL 3 MONTH); + +-- -------------------------------------------------------- + +-- +-- Schedule für Tabelle `bos_zvei` +-- + +CREATE EVENT IF NOT EXISTS `Delete ZVEI Entries > 3 Months` + ON SCHEDULE EVERY 1 DAY + STARTS '2016-01-01 00:00:00' + ON COMPLETION PRESERVE ENABLE + DO + DELETE FROM bos_zvei WHERE time < DATE_SUB(NOW(),INTERVAL 3 MONTH); From c77f2a9fdd11b72dc62d5e5da8cbb3c6c25e1341 Mon Sep 17 00:00:00 2001 From: Mikrocontroller Date: Wed, 12 Apr 2017 23:20:40 +0200 Subject: [PATCH 05/32] Encode data URL-safe, support of multiple URLs --- plugins/httpRequest/httpRequest.py | 42 +++++++++++++++++------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/plugins/httpRequest/httpRequest.py b/plugins/httpRequest/httpRequest.py index 3d8d90e..744f621 100644 --- a/plugins/httpRequest/httpRequest.py +++ b/plugins/httpRequest/httpRequest.py @@ -14,6 +14,7 @@ httpRequest-Plugin to dispatch FMS-, ZVEI- and POCSAG - messages to an URL # # Imports # +import urllib import urllib2 import logging # Global logger from includes import globalVars # Global variables @@ -67,36 +68,41 @@ def run(typ,freq,data): try: # - # Create URL + # Replace special characters in data Strings for URL + # + for key in data: + if isinstance(data[key], basestring): + data[key] = urllib.quote(data[key]) + # + # Get URLs # if typ == "FMS": - url = globalVars.config.get("httpRequest", "fms_url") #Get URL - url = wildcardHandler.replaceWildcards(url, data) # replace wildcards with helper function - url = url.replace(" ","%20") # replace space with %20 to be a vaild http request + urls = globalVars.config.get("httpRequest", "fms_url").split(",") elif typ == "ZVEI": - url = globalVars.config.get("httpRequest", "zvei_url") #Get URL - url = wildcardHandler.replaceWildcards(url, data) # replace wildcards with helper function - url = url.replace(" ","%20") # replace space with %20 to be a vaild http request + urls = globalVars.config.get("httpRequest", "zvei_url").split(",") elif typ == "POC": - url = globalVars.config.get("httpRequest", "poc_url") #Get URL - url = wildcardHandler.replaceWildcards(url, data) # replace wildcards with helper function - url = url.replace(" ","%20") # replace space with %20 to be a vaild http request + urls = globalVars.config.get("httpRequest", "poc_url").split(",") else: logging.warning("Invalid Typ: %s", typ) return # + # replace wildcards + # + for (i, url) in enumerate(urls): + urls[i] = wildcardHandler.replaceWildcards(urls[i].strip(), data) + # # HTTP-Request # - logging.debug("send %s HTTP request", typ) + logging.debug("send %s HTTP requests", typ) - try: - #resp = urllib2.urlopen(url) - urllib2.urlopen(url) - except urllib2.HTTPError as e: - logging.warning("HTTP response: %s", e.code) - except urllib2.URLError as e: - logging.warning("HTTP-specific error: %s", e.args) + for url in urls: + try: + urllib2.urlopen(url) + except urllib2.HTTPError as e: + logging.warning("HTTP response: %s", e.code) + except urllib2.URLError as e: + logging.warning("HTTP-specific error: %s", e.args) except: logging.error("cannot send HTTP request") From 4aeb413f4fbd25b5087f78133d58291ef280da09 Mon Sep 17 00:00:00 2001 From: Mikrocontroller Date: Wed, 12 Apr 2017 23:23:42 +0200 Subject: [PATCH 06/32] Added comment for multiple URLs --- config/config.template.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/config.template.ini b/config/config.template.ini index 6f7f018..2c74531 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -169,6 +169,8 @@ tableSIG = bos_signal [httpRequest] # example URL http://example.com/remote.php?DESCR=%DESCR% +# multiple URLs can be separated by comma + # you can use the following wildcards in your URL as GET params: # http://en.wikipedia.org/wiki/Query_string From 642d95b11a0f396c8b5f3dbd6b9e94f35f35be8b Mon Sep 17 00:00:00 2001 From: Florian Date: Sun, 16 Apr 2017 23:47:08 +0200 Subject: [PATCH 07/32] Enabling typ-handling Enable FMS and ZVEI-handling for plugin; message is set depending on the available information and processed to the http-handling. If typ is invalid an empty message will be sent. The text of the message can be adapted with regard to the information resulting from decoding --- plugins/Sms77/Sms77.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/Sms77/Sms77.py b/plugins/Sms77/Sms77.py index 61d9078..82ae514 100644 --- a/plugins/Sms77/Sms77.py +++ b/plugins/Sms77/Sms77.py @@ -58,6 +58,20 @@ def run(typ,freq,data): """ try: if configHandler.checkConfig("Sms77"): #read and debug the config + + # create an empty message an fill it with the required information + message = "" + if typ == "FMS": + logging.debug("FMS detected, building message") + message = data["description"]+"
"+data["status"] + elif typ == "ZVEI": + logging.debug("ZVEI detected, building message") + mesage = data["description"] + elif typ == "POC": + logging.debug("POC detected, building message") + message = data["description"]+"
"+data["msg"].replace(";", "
") + else: + logging.warning("Invalid typ - use empty message") try: @@ -74,7 +88,7 @@ def run(typ,freq,data): "to": globalVars.config.get("Sms77", "to"), "from": globalVars.config.get("Sms77", "from"), "type": globalVars.config.get("Sms77", "type"), - "text": data["description"]+"
"+data["msg"].replace(";", "
") + "text": message }),{"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}) except: From 08c671cd0992b900d7872d9b19dfe2cdfefbf956 Mon Sep 17 00:00:00 2001 From: Florian Date: Sun, 16 Apr 2017 23:48:46 +0200 Subject: [PATCH 08/32] Update Sms77.py Adapting to new API --- plugins/Sms77/Sms77.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/Sms77/Sms77.py b/plugins/Sms77/Sms77.py index 82ae514..51ce7b5 100644 --- a/plugins/Sms77/Sms77.py +++ b/plugins/Sms77/Sms77.py @@ -80,8 +80,8 @@ def run(typ,freq,data): # logging.debug("send Sms77 %s", typ) - conn = httplib.HTTPSConnection("gateway.sms77.de:443") - conn.request("POST", "", + cconn = httplib.HTTPSConnection("gateway.sms77.io",443) + conn.request("POST", "/api/sms", urllib.urlencode({ "u": globalVars.config.get("Sms77", "user"), "p": globalVars.config.get("Sms77", "password"), From 142e2ba5b01a306176c8bd7290254a48dcd2759c Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 17 Apr 2017 10:00:20 +0200 Subject: [PATCH 09/32] Fixing typo Removed double-c from conn-string --- plugins/Sms77/Sms77.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Sms77/Sms77.py b/plugins/Sms77/Sms77.py index 51ce7b5..9985873 100644 --- a/plugins/Sms77/Sms77.py +++ b/plugins/Sms77/Sms77.py @@ -80,7 +80,7 @@ def run(typ,freq,data): # logging.debug("send Sms77 %s", typ) - cconn = httplib.HTTPSConnection("gateway.sms77.io",443) + conn = httplib.HTTPSConnection("gateway.sms77.io",443) conn.request("POST", "/api/sms", urllib.urlencode({ "u": globalVars.config.get("Sms77", "user"), From 2e03519333c12fa79b00f231475e6b6a63274b53 Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 17 Apr 2017 10:46:39 +0200 Subject: [PATCH 10/32] Fixing message Set default-message to alarm Fixing ZVEI-message; it now contains zvei, and, if available, description --- plugins/Sms77/Sms77.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/Sms77/Sms77.py b/plugins/Sms77/Sms77.py index 9985873..e4353d1 100644 --- a/plugins/Sms77/Sms77.py +++ b/plugins/Sms77/Sms77.py @@ -60,13 +60,13 @@ def run(typ,freq,data): if configHandler.checkConfig("Sms77"): #read and debug the config # create an empty message an fill it with the required information - message = "" + message = "Alarm" if typ == "FMS": logging.debug("FMS detected, building message") message = data["description"]+"
"+data["status"] elif typ == "ZVEI": logging.debug("ZVEI detected, building message") - mesage = data["description"] + message = data["zvei"]+" - "+data["description"] elif typ == "POC": logging.debug("POC detected, building message") message = data["description"]+"
"+data["msg"].replace(";", "
") From 84b9d4ba6179f7eacced7540ee5fef5a28c14998 Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 19 Apr 2017 22:54:57 +0200 Subject: [PATCH 11/32] Renaming file to .template. To prevent overwritten files after an update the csv-file is renamed to .template.csv --- csv/{fms.csv => fms.template.csv} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename csv/{fms.csv => fms.template.csv} (100%) diff --git a/csv/fms.csv b/csv/fms.template.csv similarity index 100% rename from csv/fms.csv rename to csv/fms.template.csv From fb4c922fef358ffe163bc92f6fc7b8dc38b1e233 Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 19 Apr 2017 22:55:32 +0200 Subject: [PATCH 12/32] Rename nma.csv to nma.template.csv To prevent overwritten files after an update the csv-file is renamed to .template.csv --- csv/{nma.csv => nma.template.csv} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename csv/{nma.csv => nma.template.csv} (100%) diff --git a/csv/nma.csv b/csv/nma.template.csv similarity index 100% rename from csv/nma.csv rename to csv/nma.template.csv From 20746d66db408c3f647957173b7edd8938af8ba6 Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 19 Apr 2017 22:55:55 +0200 Subject: [PATCH 13/32] Rename poc.csv to poc.template.csv To prevent overwritten files after an update the csv-file is renamed to .template.csv --- csv/{poc.csv => poc.template.csv} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename csv/{poc.csv => poc.template.csv} (100%) diff --git a/csv/poc.csv b/csv/poc.template.csv similarity index 100% rename from csv/poc.csv rename to csv/poc.template.csv From 5f4f6caa106abe253fb9f08bd888ba36b8fab56f Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 19 Apr 2017 22:56:09 +0200 Subject: [PATCH 14/32] Rename zvei.csv to zvei.template.csv To prevent overwritten files after an update the csv-file is renamed to .template.csv --- csv/{zvei.csv => zvei.template.csv} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename csv/{zvei.csv => zvei.template.csv} (100%) diff --git a/csv/zvei.csv b/csv/zvei.template.csv similarity index 100% rename from csv/zvei.csv rename to csv/zvei.template.csv From 77f51e35092b9330766f72b4975e4f2cfadc45c6 Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 19 Apr 2017 23:17:09 +0200 Subject: [PATCH 15/32] New service Implement BOSWatch as systemctl-service --- service/boswatch.service | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 service/boswatch.service diff --git a/service/boswatch.service b/service/boswatch.service new file mode 100644 index 0000000..80c440b --- /dev/null +++ b/service/boswatch.service @@ -0,0 +1,11 @@ +[Unit] +Description=BOSWatch +After=multi-user.target + +[Service] +Type=simple +ExecStart=/usr/bin/python /opt/boswatch/boswatch.py -f 123.45M -a POC512 +Restart=on-abort + +[Install] +WantedBy=multi-user.target From a2b7cb3b56590ee68adb97a974a70addffb9a244 Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 19 Apr 2017 23:22:22 +0200 Subject: [PATCH 16/32] Update README.md Adapt it to the new service --- service/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/service/README.md b/service/README.md index 3057ee4..41337a9 100644 --- a/service/README.md +++ b/service/README.md @@ -1,3 +1,20 @@ +### Use BOSWatch as service ### + +Old description below + +We assume that BOSWatch is installed to /opt/boswatch! Otherwise you need to adapt all the pathes in this description and in the service-file itself. + +#### Adapt the script +Enter the frequency and the decoder(s) you want to use in line 7; you can add more specific switches if you need to + +### Install the service +1. Copy the file to /lib/systemd/system: sudo cp /opt/boswatch/service/boswatch.service /lib/systemd/system/ +2. Change the rights: sudo chmod 644 /lib/systemd/system/boswatch.service +3. Enable the service: sudo systemcl enable boswatch.service +4. Start the service: sudo systemcl start boswatch.service + +--- + ### Start BOSWatch as a daemon ##### Changing the init script From 4e1cf00cb38a2ef1ed3078953cac59e568110612 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Plogmann Date: Mon, 24 Apr 2017 20:08:37 +0200 Subject: [PATCH 17/32] read message-text from config --- config/config.template.ini | 39 +++++++++++++++++++++++++++++++++--- plugins/Telegram/Telegram.py | 16 +++++++++------ 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/config/config.template.ini b/config/config.template.ini index 2c74531..a8f141c 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -414,14 +414,47 @@ RICforLocationAPIKey = # This is your Google API key. # Required if you want to create a map based on location information received with the above RIC. GoogleAPIKey = + +# %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) +# %LPAR% = ( +# %RPAR% = ) +fms_message = %DATE% %TIME%: %FMS% + +# %ZVEI% = ZVEI 5-tone Code +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %LPAR% = ( +# %RPAR% = ) +zvei_message = %DATE% %TIME%: %ZVEI% + +# %RIC% = POCSAG RIC +# %FUNC% = POCSAG function/Subric (1-4) +# %FUNCCHAR% = POCSAG function/Subric als character (a-d) +# %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) +# %LPAR% = ( +# %RPAR% = ) +poc_message = %MSG% + [yowsup] # number or chat-number who whants to become the news -empfaenger = +empfaenger = # WhatsApp-number of that the news comes -sender = +sender = # password from this number -password= +password= # %FMS% = FMS Code # %STATUS% = FMS Status diff --git a/plugins/Telegram/Telegram.py b/plugins/Telegram/Telegram.py index 0d890c8..0b4c053 100644 --- a/plugins/Telegram/Telegram.py +++ b/plugins/Telegram/Telegram.py @@ -16,6 +16,7 @@ from telegram.error import (TelegramError, Unauthorized, BadRequest, NetworkErro from includes import globalVars # Global variables # Helper function, uncomment to use +from includes.helper import wildcardHandler from includes.helper import configHandler from includes.helper import timeHandler @@ -81,14 +82,15 @@ def run(typ,freq,data): if typ == "POC": logging.debug("Compose output from POCSAG-message") # compose message content - output = timeHandler.curtime()+"\n"+data["ric"]+"("+data["functionChar"]+")\n"+data["description"]+"\n"+data["msg"] + text = globalVars.config.get("Telegram","poc_message") + text = wildcardHandler.replaceWildcards(text, data) # Initiate Telegram Bot logging.debug("Initiate Telegram BOT") bot = telegram.Bot(token='%s' % BOTTokenAPIKey) # Send message to chat via Telegram BOT API logging.debug("Send message to chat via Telegram BOT API") - bot.sendMessage('%s' % BOTChatIDAPIKey, output) + bot.sendMessage('%s' % BOTChatIDAPIKey, "text") # Generate location information only for specific RIC if data["ric"] == RICforLocationAPIKey: @@ -116,25 +118,27 @@ def run(typ,freq,data): elif typ == "FMS": logging.debug("Compose output from FMS-message") # compose message content - output = timeHandler.curtime()+"\n"+data["fms"]+"\n"+data["description"]+"\n"+data["status"] + text = globalVars.config.get("Telegram","fms_message") + text = wildcardHandler.replaceWildcards(text, data) # Initiate Telegram Bot logging.debug("Initiate Telegram BOT") bot = telegram.Bot(token='%s' % BOTTokenAPIKey) # Send message to chat via Telegram BOT API logging.debug("Send message to chat via Telegram BOT API") - bot.sendMessage('%s' % BOTChatIDAPIKey, output) + bot.sendMessage('%s' % BOTChatIDAPIKey, "text") elif typ == "ZVEI": logging.debug("Compose output from ZVEI-message") # compose message content - output = timeHandler.curtime()+"\n"+data["zvei"]+"\n"+data["description"] + text = globalVars.config.get("Telegram","zvei_message") + text = wildcardHandler.replaceWildcards(text, data) # Initiate Telegram Bot logging.debug("Initiate Telegram BOT") bot = telegram.Bot(token='%s' % BOTTokenAPIKey) # Send message to chat via Telegram BOT API logging.debug("Send message to chat via Telegram BOT API") - bot.sendMessage('%s' % BOTChatIDAPIKey, output) + bot.sendMessage('%s' % BOTChatIDAPIKey, "text") else: logging.warning("Invalid Typ: %s", typ) except Unauthorized: From d99574239bccbb7936f1f2ccbefc7ee99b63c505 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Plogmann Date: Mon, 24 Apr 2017 20:17:07 +0200 Subject: [PATCH 18/32] fixed syntax issues --- plugins/Telegram/Telegram.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/Telegram/Telegram.py b/plugins/Telegram/Telegram.py index 0b4c053..484880c 100644 --- a/plugins/Telegram/Telegram.py +++ b/plugins/Telegram/Telegram.py @@ -90,7 +90,7 @@ def run(typ,freq,data): bot = telegram.Bot(token='%s' % BOTTokenAPIKey) # Send message to chat via Telegram BOT API logging.debug("Send message to chat via Telegram BOT API") - bot.sendMessage('%s' % BOTChatIDAPIKey, "text") + bot.sendMessage('%s' % BOTChatIDAPIKey, text) # Generate location information only for specific RIC if data["ric"] == RICforLocationAPIKey: @@ -126,7 +126,7 @@ def run(typ,freq,data): bot = telegram.Bot(token='%s' % BOTTokenAPIKey) # Send message to chat via Telegram BOT API logging.debug("Send message to chat via Telegram BOT API") - bot.sendMessage('%s' % BOTChatIDAPIKey, "text") + bot.sendMessage('%s' % BOTChatIDAPIKey, text) elif typ == "ZVEI": logging.debug("Compose output from ZVEI-message") # compose message content @@ -138,7 +138,7 @@ def run(typ,freq,data): bot = telegram.Bot(token='%s' % BOTTokenAPIKey) # Send message to chat via Telegram BOT API logging.debug("Send message to chat via Telegram BOT API") - bot.sendMessage('%s' % BOTChatIDAPIKey, "text") + bot.sendMessage('%s' % BOTChatIDAPIKey, text) else: logging.warning("Invalid Typ: %s", typ) except Unauthorized: From d3cbbb60d8c9c389445db5725e8375f49e04714e Mon Sep 17 00:00:00 2001 From: Jockel Date: Tue, 25 Apr 2017 06:53:15 +0200 Subject: [PATCH 19/32] added missing lineBrakeAllowed=True --- plugins/Telegram/Telegram.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/Telegram/Telegram.py b/plugins/Telegram/Telegram.py index 484880c..a9de8d6 100644 --- a/plugins/Telegram/Telegram.py +++ b/plugins/Telegram/Telegram.py @@ -83,8 +83,7 @@ def run(typ,freq,data): logging.debug("Compose output from POCSAG-message") # compose message content text = globalVars.config.get("Telegram","poc_message") - text = wildcardHandler.replaceWildcards(text, data) - + text = wildcardHandler.replaceWildcards(text, data, lineBrakeAllowed=True) # Initiate Telegram Bot logging.debug("Initiate Telegram BOT") bot = telegram.Bot(token='%s' % BOTTokenAPIKey) @@ -119,7 +118,7 @@ def run(typ,freq,data): logging.debug("Compose output from FMS-message") # compose message content text = globalVars.config.get("Telegram","fms_message") - text = wildcardHandler.replaceWildcards(text, data) + text = wildcardHandler.replaceWildcards(text, data, lineBrakeAllowed=True) # Initiate Telegram Bot logging.debug("Initiate Telegram BOT") @@ -131,7 +130,7 @@ def run(typ,freq,data): logging.debug("Compose output from ZVEI-message") # compose message content text = globalVars.config.get("Telegram","zvei_message") - text = wildcardHandler.replaceWildcards(text, data) + text = wildcardHandler.replaceWildcards(text, data, lineBrakeAllowed=True) # Initiate Telegram Bot logging.debug("Initiate Telegram BOT") From 80a9cdb6f4ea69c6b425fd62cb1e3da089ff3e03 Mon Sep 17 00:00:00 2001 From: Jockel Date: Tue, 25 Apr 2017 10:52:03 +0200 Subject: [PATCH 20/32] removed lineBrakeAllowed --- includes/helper/wildcardHandler.py | 7 ++----- plugins/Telegram/Telegram.py | 6 +++--- plugins/eMail/eMail.py | 6 +++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/includes/helper/wildcardHandler.py b/includes/helper/wildcardHandler.py index d67dde2..e85e6f8 100644 --- a/includes/helper/wildcardHandler.py +++ b/includes/helper/wildcardHandler.py @@ -17,7 +17,7 @@ from includes import globalVars from includes.helper import timeHandler -def replaceWildcards(text, data, lineBrakeAllowed=False): +def replaceWildcards(text, data): """ Replace all official Wildcards with the Information from the data[] var @@ -25,8 +25,6 @@ def replaceWildcards(text, data, lineBrakeAllowed=False): @param text: Input text with wildcards @type data: map @param data: map of data (structure see readme.md in plugin folder) - @type lineBrakeAllowed: Boolean - @param lineBrakeAllowed: switch to allow lineBreak (%BR%) as wildcard @return: text with replaced wildcards @exception: Exception if Error at replace @@ -36,8 +34,7 @@ def replaceWildcards(text, data, lineBrakeAllowed=False): text = text.replace("%TIME%", timeHandler.getTime(data["timestamp"])).replace("%DATE%", timeHandler.getDate(data["timestamp"])) # replace some special chars - if lineBrakeAllowed == True: - text = text.replace("%BR%", "\r\n") + text = text.replace("%BR%", "\r\n") text = text.replace("%LPAR%", "(") text = text.replace("%RPAR%", ")") diff --git a/plugins/Telegram/Telegram.py b/plugins/Telegram/Telegram.py index a9de8d6..9cc3246 100644 --- a/plugins/Telegram/Telegram.py +++ b/plugins/Telegram/Telegram.py @@ -83,7 +83,7 @@ def run(typ,freq,data): logging.debug("Compose output from POCSAG-message") # compose message content text = globalVars.config.get("Telegram","poc_message") - text = wildcardHandler.replaceWildcards(text, data, lineBrakeAllowed=True) + text = wildcardHandler.replaceWildcards(text, data) # Initiate Telegram Bot logging.debug("Initiate Telegram BOT") bot = telegram.Bot(token='%s' % BOTTokenAPIKey) @@ -118,7 +118,7 @@ def run(typ,freq,data): logging.debug("Compose output from FMS-message") # compose message content text = globalVars.config.get("Telegram","fms_message") - text = wildcardHandler.replaceWildcards(text, data, lineBrakeAllowed=True) + text = wildcardHandler.replaceWildcards(text, data) # Initiate Telegram Bot logging.debug("Initiate Telegram BOT") @@ -130,7 +130,7 @@ def run(typ,freq,data): logging.debug("Compose output from ZVEI-message") # compose message content text = globalVars.config.get("Telegram","zvei_message") - text = wildcardHandler.replaceWildcards(text, data, lineBrakeAllowed=True) + text = wildcardHandler.replaceWildcards(text, data) # Initiate Telegram Bot logging.debug("Initiate Telegram BOT") diff --git a/plugins/eMail/eMail.py b/plugins/eMail/eMail.py index d054c85..ec271b2 100644 --- a/plugins/eMail/eMail.py +++ b/plugins/eMail/eMail.py @@ -137,7 +137,7 @@ def run(typ,freq,data): # read mailtext-structure from config.ini mailtext = globalVars.config.get("eMail", "fms_message") # replace wildcards with helper function - mailtext = wildcardHandler.replaceWildcards(mailtext, data, lineBrakeAllowed=True) + mailtext = wildcardHandler.replaceWildcards(mailtext, data) # send eMail doSendmail(server, subject, mailtext) @@ -157,7 +157,7 @@ def run(typ,freq,data): # read mailtext-structure from config.ini mailtext = globalVars.config.get("eMail", "zvei_message") # replace wildcards with helper function - mailtext = wildcardHandler.replaceWildcards(mailtext, data, lineBrakeAllowed=True) + mailtext = wildcardHandler.replaceWildcards(mailtext, data) # send eMail doSendmail(server, subject, mailtext) @@ -177,7 +177,7 @@ def run(typ,freq,data): # read mailtext-structure from config.ini mailtext = globalVars.config.get("eMail", "poc_message") # replace wildcards with helper function - mailtext = wildcardHandler.replaceWildcards(mailtext, data, lineBrakeAllowed=True) + mailtext = wildcardHandler.replaceWildcards(mailtext, data) # send eMail doSendmail(server, subject, mailtext) From de451ffc6f29ab34555fb5f5191af6a4e5b0f3f3 Mon Sep 17 00:00:00 2001 From: Jan Bollacke Date: Thu, 27 Apr 2017 14:39:23 +0200 Subject: [PATCH 21/32] DescriptionList: check if a description exists for ric w/o the subric --- includes/descriptionList.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/descriptionList.py b/includes/descriptionList.py index cca894f..8755d08 100644 --- a/includes/descriptionList.py +++ b/includes/descriptionList.py @@ -113,6 +113,8 @@ def getDescription(typ, data): elif typ == "POC": global ricDescribtionList resultStr = ricDescribtionList[data] + if not resultStr: + resultStr = ricDescribtionList[data[:-1]] else: logging.warning("Invalid Typ: %s", typ) From 58b3158e9a3e2bc3b1b1804616b80b7a99972002 Mon Sep 17 00:00:00 2001 From: Jan Bollacke Date: Thu, 27 Apr 2017 14:40:42 +0200 Subject: [PATCH 22/32] PocDecoder: use subric in description lookup --- includes/decoders/poc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index 46be042..457178d 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -126,7 +126,7 @@ def decode(freq, decoded): # If enabled, look up description if globalVars.config.getint("POC", "idDescribed"): from includes import descriptionList - data["description"] = descriptionList.getDescription("POC", poc_id) + data["description"] = descriptionList.getDescription("POC", poc_id+poc_sub) # processing the alarm try: from includes import alarmHandler From 5ccd6d8cc0ae863e370bf9c35fe2756a8228a56e Mon Sep 17 00:00:00 2001 From: Jan Bollacke Date: Fri, 28 Apr 2017 07:44:12 +0200 Subject: [PATCH 23/32] DescriptionList: support functionchar while loading ids/rics --- includes/descriptionList.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/descriptionList.py b/includes/descriptionList.py index 8755d08..22ba728 100644 --- a/includes/descriptionList.py +++ b/includes/descriptionList.py @@ -11,6 +11,7 @@ Function to expand the dataset with a description. import logging # Global logger import csv # for loading the description files +import re # for matching IDs with a regular expression from includes import globalVars # Global variables from includes.helper import stringConverter @@ -41,8 +42,8 @@ def loadCSV(typ, idField): reader = csv.DictReader(csvfile) for row in reader: logging.debug(row) - # only import rows with an integer as id - if row[idField].isdigit() == True: + # only import rows with an integer as id, allow subrics though + if re.match("^[0-9]+[A-D]?$", idField, re.IGNORECASE): try: resultList[row[idField]] = stringConverter.convertToUTF8(row['description']) except: From a4c218887b6392c3bbcb1498de9ae0923356e4d2 Mon Sep 17 00:00:00 2001 From: Jan Bollacke Date: Fri, 28 Apr 2017 07:45:23 +0200 Subject: [PATCH 24/32] DescriptionList: fix lookup for ric and subric --- includes/descriptionList.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/includes/descriptionList.py b/includes/descriptionList.py index 22ba728..7e959b7 100644 --- a/includes/descriptionList.py +++ b/includes/descriptionList.py @@ -113,9 +113,8 @@ def getDescription(typ, data): resultStr = zveiDescribtionList[data] elif typ == "POC": global ricDescribtionList - resultStr = ricDescribtionList[data] - if not resultStr: - resultStr = ricDescribtionList[data[:-1]] + resultStr = ricDescribtionList[data[:-1]] # MainRIC + resultStr += " " + ricDescribtionList[data] # SubRIC else: logging.warning("Invalid Typ: %s", typ) From bf9a604931a14f7d4a8dbaf29b8a8cb08451296e Mon Sep 17 00:00:00 2001 From: Jan Bollacke Date: Fri, 28 Apr 2017 07:46:28 +0200 Subject: [PATCH 25/32] PocDecoder: use functionchar instead of subric in description lookup --- includes/decoders/poc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/decoders/poc.py b/includes/decoders/poc.py index 457178d..b0198f0 100644 --- a/includes/decoders/poc.py +++ b/includes/decoders/poc.py @@ -126,7 +126,7 @@ def decode(freq, decoded): # If enabled, look up description if globalVars.config.getint("POC", "idDescribed"): from includes import descriptionList - data["description"] = descriptionList.getDescription("POC", poc_id+poc_sub) + data["description"] = descriptionList.getDescription("POC", poc_id+data["functionChar"]) # processing the alarm try: from includes import alarmHandler From 4e23d9856edc3f574494cc919fdfe11a4ebc3f37 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 28 Apr 2017 23:02:50 +0200 Subject: [PATCH 26/32] Fixing regex Searching in wrong field leads to error - fixing it --- includes/descriptionList.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/descriptionList.py b/includes/descriptionList.py index 7e959b7..e9252b3 100644 --- a/includes/descriptionList.py +++ b/includes/descriptionList.py @@ -43,7 +43,7 @@ def loadCSV(typ, idField): for row in reader: logging.debug(row) # only import rows with an integer as id, allow subrics though - if re.match("^[0-9]+[A-D]?$", idField, re.IGNORECASE): + if re.match("^[0-9]+[A-D]?$", row[idField], re.IGNORECASE): try: resultList[row[idField]] = stringConverter.convertToUTF8(row['description']) except: From 418411e09cfd4dd97e3ec2e1aa7d0c175ec6fdd7 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 28 Apr 2017 23:49:44 +0200 Subject: [PATCH 27/32] Converting everything to lowercase Ignore upper- or lowercase from csv-file - as the code translates to lowercase in poc.csv all entries will be switched to lowercase. --- includes/descriptionList.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/descriptionList.py b/includes/descriptionList.py index e9252b3..fba47f1 100644 --- a/includes/descriptionList.py +++ b/includes/descriptionList.py @@ -45,6 +45,10 @@ def loadCSV(typ, idField): # only import rows with an integer as id, allow subrics though if re.match("^[0-9]+[A-D]?$", row[idField], re.IGNORECASE): try: + if len(row[idField]) > 7: + if row[idField][7].isupper(): + tmp = row[idField].lower() + row[idField] = tmp; resultList[row[idField]] = stringConverter.convertToUTF8(row['description']) except: # skip entry in case of an exception From aeedcd4c8c9f61e3d06ae9ac0b1600b267b4d66c Mon Sep 17 00:00:00 2001 From: Jan Bollacke Date: Mon, 1 May 2017 09:14:45 +0200 Subject: [PATCH 28/32] DescriptionList: Simplify conversion of keys to lowercase This reverts commit 418411e09cfd4dd97e3ec2e1aa7d0c175ec6fdd7. --- includes/descriptionList.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/includes/descriptionList.py b/includes/descriptionList.py index fba47f1..848d39a 100644 --- a/includes/descriptionList.py +++ b/includes/descriptionList.py @@ -45,11 +45,7 @@ def loadCSV(typ, idField): # only import rows with an integer as id, allow subrics though if re.match("^[0-9]+[A-D]?$", row[idField], re.IGNORECASE): try: - if len(row[idField]) > 7: - if row[idField][7].isupper(): - tmp = row[idField].lower() - row[idField] = tmp; - resultList[row[idField]] = stringConverter.convertToUTF8(row['description']) + resultList[row[idField].lower()] = stringConverter.convertToUTF8(row['description']) except: # skip entry in case of an exception pass From 3e1db59d462bdc05c59d5d34cdd9edf972ee7b8a Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Sun, 7 May 2017 13:37:35 +0200 Subject: [PATCH 29/32] Update config.template.ini --- config/config.template.ini | 66 +++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/config/config.template.ini b/config/config.template.ini index a8f141c..d943faf 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -414,39 +414,39 @@ RICforLocationAPIKey = # This is your Google API key. # Required if you want to create a map based on location information received with the above RIC. GoogleAPIKey = - -# %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) -# %LPAR% = ( -# %RPAR% = ) -fms_message = %DATE% %TIME%: %FMS% - -# %ZVEI% = ZVEI 5-tone Code -# %DESCR% = Description, if description-module is used -# %DATE% = Date (by script) -# %TIME% = Time (by script) -# %LPAR% = ( -# %RPAR% = ) -zvei_message = %DATE% %TIME%: %ZVEI% - -# %RIC% = POCSAG RIC -# %FUNC% = POCSAG function/Subric (1-4) -# %FUNCCHAR% = POCSAG function/Subric als character (a-d) -# %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) -# %LPAR% = ( -# %RPAR% = ) -poc_message = %MSG% - + +# %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) +# %LPAR% = ( +# %RPAR% = ) +FMS_message = %DATE% %TIME%: %FMS% + +# %ZVEI% = ZVEI 5-tone Code +# %DESCR% = Description, if description-module is used +# %DATE% = Date (by script) +# %TIME% = Time (by script) +# %LPAR% = ( +# %RPAR% = ) +ZVEI_message = %DATE% %TIME%: %ZVEI% + +# %RIC% = POCSAG RIC +# %FUNC% = POCSAG function/Subric (1-4) +# %FUNCCHAR% = POCSAG function/Subric als character (a-d) +# %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) +# %LPAR% = ( +# %RPAR% = ) +POC_message = %MSG% + [yowsup] # number or chat-number who whants to become the news From 78092389e90a5de593adb1c83361283f69d159db Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Sun, 7 May 2017 13:38:30 +0200 Subject: [PATCH 30/32] Update Telegram.py Removal of duplicate code. --- plugins/Telegram/Telegram.py | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/plugins/Telegram/Telegram.py b/plugins/Telegram/Telegram.py index 9cc3246..606fd9d 100644 --- a/plugins/Telegram/Telegram.py +++ b/plugins/Telegram/Telegram.py @@ -18,7 +18,6 @@ from includes import globalVars # Global variables # Helper function, uncomment to use from includes.helper import wildcardHandler from includes.helper import configHandler -from includes.helper import timeHandler # local variables BOTTokenAPIKey = None @@ -79,11 +78,12 @@ def run(typ,freq,data): try: ########## User Plugin CODE ########## try: - if typ == "POC": - logging.debug("Compose output from POCSAG-message") + if typ == "POC" or typ == "FMS" or typ == "ZVEI": + logging.debug("Read format and compose output for %s-message" % typ) # compose message content - text = globalVars.config.get("Telegram","poc_message") + text = globalVars.config.get("Telegram", "%s_message" % typ) text = wildcardHandler.replaceWildcards(text, data) + # Initiate Telegram Bot logging.debug("Initiate Telegram BOT") bot = telegram.Bot(token='%s' % BOTTokenAPIKey) @@ -92,7 +92,7 @@ def run(typ,freq,data): bot.sendMessage('%s' % BOTChatIDAPIKey, text) # Generate location information only for specific RIC - if data["ric"] == RICforLocationAPIKey: + if typ == "POC" and data["ric"] == RICforLocationAPIKey: # Generate map logging.debug("Extract address from POCSAG message") address = "+".join(data["msg"].split(')')[0].split('/',1)[1].replace('(',' ').split()) @@ -114,30 +114,6 @@ def run(typ,freq,data): gcode_result = gcode.geocode(address) logging.debug("Send location via Telegram BOT API") bot.sendLocation('%s' % BOTChatIDAPIKey, gcode_result[0]['geometry']['location']['lat'], gcode_result[0]['geometry']['location']['lng'], disable_notification='true') - elif typ == "FMS": - logging.debug("Compose output from FMS-message") - # compose message content - text = globalVars.config.get("Telegram","fms_message") - text = wildcardHandler.replaceWildcards(text, data) - - # Initiate Telegram Bot - logging.debug("Initiate Telegram BOT") - bot = telegram.Bot(token='%s' % BOTTokenAPIKey) - # Send message to chat via Telegram BOT API - logging.debug("Send message to chat via Telegram BOT API") - bot.sendMessage('%s' % BOTChatIDAPIKey, text) - elif typ == "ZVEI": - logging.debug("Compose output from ZVEI-message") - # compose message content - text = globalVars.config.get("Telegram","zvei_message") - text = wildcardHandler.replaceWildcards(text, data) - - # Initiate Telegram Bot - logging.debug("Initiate Telegram BOT") - bot = telegram.Bot(token='%s' % BOTTokenAPIKey) - # Send message to chat via Telegram BOT API - logging.debug("Send message to chat via Telegram BOT API") - bot.sendMessage('%s' % BOTChatIDAPIKey, text) else: logging.warning("Invalid Typ: %s", typ) except Unauthorized: From d7896459caa18014e11de8266f45a757d20022eb Mon Sep 17 00:00:00 2001 From: PeterLaemmle Date: Sun, 7 May 2017 19:23:45 +0200 Subject: [PATCH 31/32] Update Telegram.py --- plugins/Telegram/Telegram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Telegram/Telegram.py b/plugins/Telegram/Telegram.py index 606fd9d..fc4acc7 100644 --- a/plugins/Telegram/Telegram.py +++ b/plugins/Telegram/Telegram.py @@ -78,7 +78,7 @@ def run(typ,freq,data): try: ########## User Plugin CODE ########## try: - if typ == "POC" or typ == "FMS" or typ == "ZVEI": + if typ in ("POC", "FMS", "ZVEI"): logging.debug("Read format and compose output for %s-message" % typ) # compose message content text = globalVars.config.get("Telegram", "%s_message" % typ) From f2e7c00feeacfb7e6464efe59c778839bef3890c Mon Sep 17 00:00:00 2001 From: Florian Date: Sun, 14 May 2017 22:53:42 +0200 Subject: [PATCH 32/32] Fix for leading zeros in RIC Prevent from cutting leading zeros in signal-RIC --- plugins/MySQL/MySQL.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/MySQL/MySQL.py b/plugins/MySQL/MySQL.py index 02be083..5941571 100644 --- a/plugins/MySQL/MySQL.py +++ b/plugins/MySQL/MySQL.py @@ -111,9 +111,9 @@ def run(typ,freq,data): elif typ == "POC": if isSignal(data["ric"]): - cursor.execute("UPDATE "+globalVars.config.get("MySQL","tableSIG")+" SET time = NOW() WHERE ric = "+data["ric"]) + cursor.execute("UPDATE "+globalVars.config.get("MySQL","tableSIG")+" SET time = NOW() WHERE ric = '"+data["ric"]+"';") if cursor.rowcount == 0: - cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableSIG")+" (time,ric) VALUES (NOW(),"+data["ric"]+")") + cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tableSIG")+" (time,ric) VALUES (NOW(), '"+data["ric"]+"');") else: cursor.execute("INSERT INTO "+globalVars.config.get("MySQL","tablePOC")+" (time, ric, function, functionChar, msg, bitrate, description) VALUES (FROM_UNIXTIME(%s),%s,%s,%s,%s,%s,%s)", (data["timestamp"], data["ric"], data["function"], data["functionChar"], data["msg"], data["bitrate"], data["description"]))