mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-01-24 17:10:23 +01:00
a little bit documentation
This commit is contained in:
parent
1ee27afbf0
commit
0a621b283a
|
|
@ -7,8 +7,8 @@ Python Script to receive and decode German BOS Information with rtl_fm and multi
|
|||
Through a simple plugin system, data can easily be transferred to other applications
|
||||
For more Information see the README.md
|
||||
|
||||
Autor: Bastian Schroll
|
||||
Autor: Jens Hermann
|
||||
@author: Bastian Schroll
|
||||
@author: Jens Herrmann
|
||||
|
||||
GitHUB: https://github.com/Schrolli91/BOSWatch
|
||||
"""
|
||||
|
|
@ -25,7 +25,9 @@ import subprocess
|
|||
from includes import globals # Global variables
|
||||
|
||||
##
|
||||
#
|
||||
# This Class extended the TimedRotatingFileHandler with the possibility to change the backupCount after initialization.
|
||||
#
|
||||
##
|
||||
class MyTimedRotatingFileHandler(logging.handlers.TimedRotatingFileHandler):
|
||||
"""Extended Version of TimedRotatingFileHandler"""
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ backupCount = 7
|
|||
|
||||
#Using RegEx-Filter (0|1)
|
||||
#Filter-configuration in section [Filters]
|
||||
useRegExFilter = 1
|
||||
useRegExFilter = 0
|
||||
|
||||
[FMS]
|
||||
#time to ignore same alarm in a row (sek)
|
||||
|
|
@ -118,7 +118,7 @@ fms_url =
|
|||
zvei_url =
|
||||
|
||||
# %RIC% = Pocsag RIC
|
||||
# %FUNC% = Pocsac fcuntion/Subric
|
||||
# %FUNC% = Pocsac function/Subric
|
||||
# %MSG% = Message of the Pocsag telegram
|
||||
# %BITRATE% = Bitrate of the Pocsag telegram
|
||||
#poc_url = www.google.de?ric=%RIC%&subric=%FUNC%&msg=%MSG%
|
||||
|
|
|
|||
|
|
@ -15,8 +15,11 @@ import re #Regex for validation
|
|||
|
||||
from includes import globals # Global variables
|
||||
|
||||
#FMS Decoder Function
|
||||
#validate -> check double alarm -> log
|
||||
##
|
||||
#
|
||||
# FMS Decoder Function
|
||||
# validate -> check double alarm -> log
|
||||
#
|
||||
def decode(freq, decoded):
|
||||
"""
|
||||
Export FMS Information from Multimon-NG RAW String and call alarmHandler.processAlarm()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
POCSAG Decoder
|
||||
|
||||
@author: Bastian Schroll
|
||||
@author: Jens Hermann
|
||||
@author: Jens Herrmann
|
||||
|
||||
@requires: Configuration has to be set in the config.ini
|
||||
"""
|
||||
|
|
@ -16,7 +16,10 @@ import re #Regex for validation
|
|||
|
||||
from includes import globals # Global variables
|
||||
|
||||
##
|
||||
#
|
||||
# Simple Filter
|
||||
#
|
||||
def isAllowed(poc_id):
|
||||
"""
|
||||
Simple Filter Functions (Allowed, Denied and Range)
|
||||
|
|
@ -51,9 +54,11 @@ def isAllowed(poc_id):
|
|||
return False
|
||||
return True
|
||||
|
||||
|
||||
#POCSAG Decoder Function
|
||||
#validate -> check double alarm -> log
|
||||
##
|
||||
#
|
||||
# POCSAG Decoder Function
|
||||
# validate -> check double alarm -> log
|
||||
#
|
||||
def decode(freq, decoded):
|
||||
"""
|
||||
Export POCSAG Information from Multimon-NG RAW String and call alarmHandler.processAlarm()
|
||||
|
|
|
|||
|
|
@ -15,8 +15,11 @@ import re #Regex for validation
|
|||
|
||||
from includes import globals # Global variables
|
||||
|
||||
#ZVEI Decoder Function
|
||||
#validate -> check double alarm -> log
|
||||
##
|
||||
#
|
||||
# ZVEI Decoder Function
|
||||
# validate -> check double alarm -> log
|
||||
#
|
||||
def decode(freq, decoded):
|
||||
"""
|
||||
Export ZVEI Information from Multimon-NG RAW String and call alarmHandler.processAlarm()
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
"""
|
||||
Global variables
|
||||
|
||||
@author: Jens Hermann
|
||||
@author: Jens Herrmann
|
||||
@author: Bastian Schroll
|
||||
"""
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
Shows the Header in Shell if quiet Mode is not active
|
||||
|
||||
@author: Bastian Schroll
|
||||
@author: Jens Hermann
|
||||
@author: Jens Herrmann
|
||||
|
||||
@requires: none
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ from includes import globals # Global variables
|
|||
#
|
||||
def bosMonRequest(httprequest, params, headers):
|
||||
"""
|
||||
Local function to dispatch the BosMon-Request
|
||||
This local function dispatch the BosMon-Request
|
||||
|
||||
@type httprequest: HTTPConnection
|
||||
@param httprequest: An HTTPConnection-Object that represents an open connection to a BosMon-Instance
|
||||
|
|
@ -38,10 +38,16 @@ def bosMonRequest(httprequest, params, headers):
|
|||
@exception: Exception if httprequest.request failed
|
||||
"""
|
||||
try:
|
||||
#
|
||||
# BosMon/HTTP-Request
|
||||
#
|
||||
httprequest.request("POST", "/telegramin/"+globals.config.get("BosMon", "bosmon_channel")+"/input.xml", params, headers)
|
||||
except:
|
||||
logging.exception("request to BosMon failed")
|
||||
else:
|
||||
#
|
||||
# check HTTP-Response
|
||||
#
|
||||
httpresponse = httprequest.getresponse()
|
||||
if str(httpresponse.status) == "200": #Check HTTP Response an print a Log or Error
|
||||
logging.debug("BosMon response: %s - %s", str(httpresponse.status), str(httpresponse.reason))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,16 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: cp1252 -*-
|
||||
|
||||
"""
|
||||
MySQL-Plugin to dispatch FMS-, ZVEI- and POCSAG - messages to a MySQL database
|
||||
|
||||
@author: Jens Herrmann
|
||||
@author: Bastian Schroll
|
||||
|
||||
@requires: MySQL-Configuration has to be set in the config.ini
|
||||
@requires: Created Database/Tables, see boswatch.sql
|
||||
"""
|
||||
|
||||
import logging # Global logger
|
||||
|
||||
import mysql
|
||||
|
|
@ -9,7 +19,35 @@ import mysql.connector
|
|||
from includes import globals # Global variables
|
||||
|
||||
|
||||
##
|
||||
#
|
||||
# Main function of MySQL-plugin
|
||||
# will be called by the alarmHandler
|
||||
#
|
||||
def run(typ,freq,data):
|
||||
"""
|
||||
This function is the implementation of the MySQL-Plugin.
|
||||
It will store the data to an MySQL database
|
||||
|
||||
The configuration for the MySQL-Connection is set in the config.ini.
|
||||
For DB- and tablestructure see boswatch.sql
|
||||
|
||||
@type typ: string (FMS|ZVEI|POC)
|
||||
@param typ: Typ of the dataset for sending to BosMon
|
||||
@type data: map of data (structure see interface.txt)
|
||||
@param data: Contains the parameter for dispatch to BosMon.
|
||||
@type freq: string
|
||||
@keyword freq: frequency is not used in this plugin
|
||||
|
||||
@requires: MySQL-Configuration has to be set in the config.ini
|
||||
@requires: Created Database/Tables, see boswatch.sql
|
||||
|
||||
@return: nothing
|
||||
@exception: Exception if ConfigParser failed
|
||||
@exception: Exception if connect to MySQL failed
|
||||
@exception: Exception if executing the sql-statement is failed
|
||||
"""
|
||||
|
||||
try:
|
||||
#ConfigParser
|
||||
logging.debug("reading config file")
|
||||
|
|
@ -20,14 +58,19 @@ def run(typ,freq,data):
|
|||
logging.exception("cannot read config file")
|
||||
|
||||
try:
|
||||
#
|
||||
# Connect to MySQL
|
||||
#
|
||||
logging.debug("connect to MySQL")
|
||||
connection = mysql.connector.connect(host = globals.config.get("MySQL","dbserver"), user = globals.config.get("MySQL","dbuser"), passwd = globals.config.get("MySQL","dbpassword"), db = globals.config.get("MySQL","database"))
|
||||
cursor = connection.cursor()
|
||||
except:
|
||||
logging.exception("cannot connect to MySQL")
|
||||
else:
|
||||
|
||||
try:
|
||||
#
|
||||
# Create and execute SQL-statement
|
||||
#
|
||||
logging.debug("Insert %s", typ)
|
||||
|
||||
if typ == "FMS":
|
||||
|
|
|
|||
|
|
@ -16,6 +16,11 @@ from urlparse import urlparse #for split the URL into url and path
|
|||
from includes import globals # Global variables
|
||||
|
||||
|
||||
##
|
||||
#
|
||||
# Main function of HTTP-plugin
|
||||
# will be called by the alarmHandler
|
||||
#
|
||||
def run(typ,freq,data):
|
||||
"""
|
||||
This function is the implementation of the httpRequest-Plugin.
|
||||
|
|
@ -36,7 +41,9 @@ def run(typ,freq,data):
|
|||
@exception: Exception if http Response failed
|
||||
"""
|
||||
try:
|
||||
#ConfigParser
|
||||
#
|
||||
# ConfigParser
|
||||
#
|
||||
logging.debug("reading config file")
|
||||
try:
|
||||
for key,val in globals.config.items("httpRequest"):
|
||||
|
|
@ -45,6 +52,9 @@ def run(typ,freq,data):
|
|||
logging.exception("cannot read config file")
|
||||
|
||||
try:
|
||||
#
|
||||
# Create URL
|
||||
#
|
||||
logging.debug("send %s HTTP request", typ)
|
||||
|
||||
if typ == "FMS":
|
||||
|
|
@ -61,15 +71,20 @@ def run(typ,freq,data):
|
|||
else:
|
||||
logging.warning("Invalid Typ: %s", typ)
|
||||
|
||||
url = urlparse(url)#split URL into path and querry
|
||||
#
|
||||
# HTTP-Request
|
||||
#
|
||||
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")
|
||||
else:
|
||||
|
||||
try:
|
||||
try:
|
||||
#
|
||||
# check HTTP-Response
|
||||
#
|
||||
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))
|
||||
|
|
|
|||
Loading…
Reference in a new issue