mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-01-20 15:20:16 +01:00
little changes
This commit is contained in:
parent
8c97973417
commit
475039c171
|
|
@ -130,7 +130,7 @@ try:
|
|||
logging.debug(" - Demod: POC512")
|
||||
if "POC1200" in args.demod:
|
||||
demodulation += "-a POCSAG1200 "
|
||||
logging.debug(" - Demod: P")
|
||||
logging.debug(" - Demod: POC1200")
|
||||
if "POC2400" in args.demod:
|
||||
demodulation += "-a POCSAG2400 "
|
||||
logging.debug(" - Demod: POC2400")
|
||||
|
|
|
|||
|
|
@ -101,9 +101,28 @@ bosmon_password =
|
|||
|
||||
[httpRequest]
|
||||
#URL without http://
|
||||
fms_url = www.google.de
|
||||
zvei_url = www.google.de
|
||||
poc_url = www.google.de
|
||||
|
||||
### !!! WILDCARDS actually not implemented !!! ###
|
||||
#you can use the following wildcards in your URL as GET params:
|
||||
#http://en.wikipedia.org/wiki/Query_string
|
||||
|
||||
# %FMS% = FMS Code
|
||||
# %STATUS% = FMS Status
|
||||
# %DIR% = Direction of the telegram
|
||||
# %TSI% = Tactical Short Information
|
||||
#fms_url = www.google.de?code=%FMS%&stat=%STATUS%
|
||||
fms_url =
|
||||
|
||||
# %ZVEI% = ZVEI 5-tone Code
|
||||
#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
|
||||
#poc_url = www.google.de?ric=%RIC%&subric=%FUNC%&msg=%MSG%
|
||||
poc_url =
|
||||
|
||||
|
||||
#####################
|
||||
|
|
|
|||
|
|
@ -1,32 +1,40 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: cp1252 -*-
|
||||
|
||||
#########
|
||||
# USAGE
|
||||
#
|
||||
# Config
|
||||
# ======
|
||||
# to read a option from config File
|
||||
# VALUE = globals.config.get("SECTION", "OPTION")
|
||||
#
|
||||
# Data from boswatch.py
|
||||
# =====================
|
||||
# use data["KEY"] for Alarm Data from boswatch.py
|
||||
# for usable KEYs in different Functions (FMS|ZVEI|POC) see interface.txt
|
||||
#
|
||||
# LOG Messages
|
||||
# ============
|
||||
# send Log Messages with logging.LOGLEVEL("MESSAGE")
|
||||
# usable Loglevels debug|info|warning|error|exception|critical
|
||||
# if you use .exception in Try:Exception: Construct, it logs the Python EX.message too
|
||||
"""
|
||||
httpRequest-Plugin to dispatch FMS-, ZVEI- and POCSAG - messages to an URL
|
||||
|
||||
@author: Bastian Schroll
|
||||
|
||||
@requires: httpRequest-Configuration has to be set in the config.ini
|
||||
"""
|
||||
|
||||
import logging # Global logger
|
||||
import httplib #for the HTTP request
|
||||
from urlparse import urlparse #for split the URL into url and path
|
||||
|
||||
from includes import globals # Global variables
|
||||
|
||||
|
||||
def run(typ,freq,data):
|
||||
"""
|
||||
This function is the implementation of the httpRequest-Plugin.
|
||||
It will send the data to an URL via http Request
|
||||
|
||||
@type typ: string (FMS|ZVEI|POC)
|
||||
@param typ: Typ of the dataset
|
||||
@type data: map of data (structure see interface.txt)
|
||||
@param data: Contains the parameter
|
||||
@type freq: string
|
||||
@keyword freq: frequency of the SDR Stick
|
||||
|
||||
@requires: httpRequest-Configuration has to be set in the config.ini
|
||||
|
||||
@return: nothing
|
||||
@exception: Exception if ConfigParser failed
|
||||
@exception: Exception if http Request failed
|
||||
@exception: Exception if http Response failed
|
||||
"""
|
||||
try:
|
||||
#ConfigParser
|
||||
logging.debug("reading config file")
|
||||
|
|
@ -36,41 +44,38 @@ def run(typ,freq,data):
|
|||
except:
|
||||
logging.exception("cannot read config file")
|
||||
|
||||
########## User Plugin CODE ##########
|
||||
|
||||
try:
|
||||
logging.debug("send %s HTTP request", typ)
|
||||
|
||||
if typ == "FMS":
|
||||
httprequest = httplib.HTTPConnection(globals.config.get("httpRequest", "fms_url"))
|
||||
httprequest.request("HEAD", "/")
|
||||
url = globals.config.get("httpRequest", "fms_url")
|
||||
elif typ == "ZVEI":
|
||||
httprequest = httplib.HTTPConnection(globals.config.get("httpRequest", "zvei_url"))
|
||||
httprequest.request("HEAD", "/")
|
||||
url = globals.config.get("httpRequest", "zvei_url")
|
||||
elif typ == "POC":
|
||||
httprequest = httplib.HTTPConnection(globals.config.get("httpRequest", "poc_url"))
|
||||
httprequest.request("HEAD", "/")
|
||||
url = globals.config.get("httpRequest", "poc_url")
|
||||
else:
|
||||
logging.warning("Invalid Typ: %s", typ)
|
||||
|
||||
|
||||
httprequest = httplib.HTTPConnection(url)
|
||||
httprequest.request("HEAD", path)
|
||||
|
||||
except:
|
||||
logging.exception("cannot send HTTP request")
|
||||
else:
|
||||
|
||||
try:
|
||||
httpresponse = httprequest.getresponse()
|
||||
httpresponse = httprequest.getresponse()
|
||||
if str(httpresponse.status) == "200": #Check HTTP Response an print a Log or Error
|
||||
logging.debug("HTTP response: %s - %s" , str(httpresponse.status), str(httpresponse.reason))
|
||||
else:
|
||||
logging.warning("HTTP response: %s - %s" , str(httpresponse.status), str(httpresponse.reason))
|
||||
except NameError: #if var httprequest does not exist
|
||||
logging.exception("no HTTP request been sended")
|
||||
except: #otherwise
|
||||
logging.exception("cannot get HTTP response")
|
||||
|
||||
finally:
|
||||
logging.debug("close HTTP-Connection")
|
||||
httprequest.close()
|
||||
########## User Plugin CODE ##########
|
||||
|
||||
|
||||
except:
|
||||
logging.exception("unknown error")
|
||||
Loading…
Reference in a new issue