diff --git a/README.md b/README.md index 823c018..c721dfe 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,8 @@ unless you are developer you can use the develop-Branch - may be unstable! ##### Implemented Plugins: - MySQL (insert Data into MySQL Database [FMS|ZVEI|POC]) - BosMon (send Data to BosMon Server [FMS|ZVEI|POC]) -- httpRequest (send a request to an URL [FMS|ZVEI|POC]) +- httpRequest (send a request with parameter to an URL [FMS|ZVEI|POC]) +for more Information to the Plugins see `config.ini` ##### Plugins for the Future: - E-mail Notification @@ -53,7 +54,7 @@ For the RegEX Filter Functions see Section `[Filters]` http://www.regexr.com/ - RegEX Test Tool an Documentation No Filter for a Typ/Plugin Combination = all Data pass -Syntax: INDIVIDUAL_NAME = TYP;DATAFIELD;PLUGIN;FREQUENZ;REGEX +Syntax: INDIVIDUAL_NAME = TYP;DATAFIELD;PLUGIN;FREQUENZ;REGEX (separator ";") - TYP = the Data Typ (FMS|ZVEI|POC) - DATAFIELD = the field of the Data Array (See interface.txt) - PLUGIN = the name of the Plugin to call with this Filter (* for all) diff --git a/config/config.template.ini b/config/config.template.ini index e7e07bb..99d9924 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -103,7 +103,6 @@ bosmon_password = [httpRequest] #URL without http:// -### !!! WILDCARDS actually not implemented !!! ### #you can use the following wildcards in your URL as GET params: #http://en.wikipedia.org/wiki/Query_string @@ -118,10 +117,10 @@ fms_url = #zvei_url = www.google.de?zvei=%ZVEI% zvei_url = -# %ric% = Pocsag RIC -# %func% = Pocsac fcuntion/Subric -# %msg% = Message of the Pocsag telegram -# %bitrate% = Bitrate of the Pocsag telegram +# %RIC% = Pocsag RIC +# %FUNC% = Pocsac fcuntion/Subric +# %MSG% = Message of the Pocsag telegram +# %BITRATE% = Bitrate of the Pocsag telegram #poc_url = www.google.de?ric=%RIC%&subric=%FUNC%&msg=%MSG% poc_url = diff --git a/plugins/httpRequest/httpRequest.py b/plugins/httpRequest/httpRequest.py index 7ea6d20..b36f21a 100644 --- a/plugins/httpRequest/httpRequest.py +++ b/plugins/httpRequest/httpRequest.py @@ -43,24 +43,27 @@ def run(typ,freq,data): logging.debug(" - %s = %s", key, val) except: logging.exception("cannot read config file") - try: logging.debug("send %s HTTP request", typ) if typ == "FMS": - url = globals.config.get("httpRequest", "fms_url") + url = globals.config.get("httpRequest", "fms_url") #Get URL + url = url.replace("%FMS%", data["fms"]).replace("%STATUS%", data["status"]) #replace Wildcards in URL + url = url.replace("%DIR%", data["direction"]).replace("%TSI%", data["tsi"]) #replace Wildcards in URL elif typ == "ZVEI": - url = globals.config.get("httpRequest", "zvei_url") + url = globals.config.get("httpRequest", "zvei_url") #Get URL + url = url.replace("%ZVEI%", data["zvei"]) #replace Wildcards in URL elif typ == "POC": - url = globals.config.get("httpRequest", "poc_url") + url = globals.config.get("httpRequest", "poc_url") #Get URL + url = url.replace("%RIC%", data["ric"]).replace("%FUNC%", data["function"]) #replace Wildcards in URL + url = url.replace("%MSG%", data["msg"]).replace("%BITRATE%", data["bitrate"]) #replace Wildcards in URL else: logging.warning("Invalid Typ: %s", typ) - url_path = urlparse(url)#get the URL path - - httprequest = httplib.HTTPConnection(url_path[2]) - httprequest.request("GET", url) + url = urlparse(url)#split URL into path and querry + httprequest = httplib.HTTPConnection(url[2]) #connect to URL Path + httprequest.request("GET", url[5]) #send URL Querry per GET except: logging.exception("cannot send HTTP request")