remove trailing whitespace

This commit is contained in:
Schrolli 2015-07-02 09:02:49 +02:00
parent 15f4f99012
commit 48c4d1e354
41 changed files with 352 additions and 353 deletions

View file

@ -337,4 +337,3 @@ proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. Public License instead of this License.

View file

@ -8,7 +8,7 @@ Through a simple plugin system, data can easily be transferred to other applicat
For more information see the README.md For more information see the README.md
@author: Bastian Schroll @author: Bastian Schroll
@author: Jens Herrmann @author: Jens Herrmann
Thanks to smith_fms and McBo from Funkmeldesystem.de - Forum for Inspiration and Groundwork! Thanks to smith_fms and McBo from Funkmeldesystem.de - Forum for Inspiration and Groundwork!
@ -25,20 +25,20 @@ import time # for timestamp
import subprocess # for starting rtl_fm and multimon-ng import subprocess # for starting rtl_fm and multimon-ng
from includes import globals # Global variables from includes import globals # Global variables
from includes import MyTimedRotatingFileHandler # extension of TimedRotatingFileHandler from includes import MyTimedRotatingFileHandler # extension of TimedRotatingFileHandler
from includes import converter # converter functions from includes import converter # converter functions
from includes import signalHandler # TERM-Handler for use script as a daemon from includes import signalHandler # TERM-Handler for use script as a daemon
from includes import checkSubprocesses # check startup of the subprocesses from includes import checkSubprocesses # check startup of the subprocesses
# #
# ArgParser # ArgParser
# Have to be before main program # Have to be before main program
# #
try: try:
# With -h or --help you get the Args help # With -h or --help you get the Args help
parser = argparse.ArgumentParser(prog="boswatch.py", parser = argparse.ArgumentParser(prog="boswatch.py",
description="BOSWatch is a Python Script to recive and decode german BOS information with rtl_fm and multimon-NG", description="BOSWatch is a Python Script to recive and decode german BOS information with rtl_fm and multimon-NG",
epilog="More options you can find in the extern config.ini file in the folder /config") epilog="More options you can find in the extern config.ini file in the folder /config")
# parser.add_argument("-c", "--channel", help="BOS Channel you want to listen") # parser.add_argument("-c", "--channel", help="BOS Channel you want to listen")
parser.add_argument("-f", "--freq", help="Frequency you want to listen", required=True) parser.add_argument("-f", "--freq", help="Frequency you want to listen", required=True)
@ -49,9 +49,9 @@ try:
parser.add_argument("-u", "--usevarlog", help="Use '/var/log/boswatch' for logfiles instead of subdir 'log' in BOSWatch directory", action="store_true") parser.add_argument("-u", "--usevarlog", help="Use '/var/log/boswatch' for logfiles instead of subdir 'log' in BOSWatch directory", action="store_true")
parser.add_argument("-v", "--verbose", help="Shows more information", action="store_true") parser.add_argument("-v", "--verbose", help="Shows more information", action="store_true")
parser.add_argument("-q", "--quiet", help="Shows no information. Only logfiles", action="store_true") parser.add_argument("-q", "--quiet", help="Shows no information. Only logfiles", action="store_true")
# We need this argument for testing (skip instantiate of rtl-fm and multimon-ng): # We need this argument for testing (skip instantiate of rtl-fm and multimon-ng):
parser.add_argument("-t", "--test", help=argparse.SUPPRESS, action="store_true") parser.add_argument("-t", "--test", help=argparse.SUPPRESS, action="store_true")
args = parser.parse_args() args = parser.parse_args()
except SystemExit: except SystemExit:
# -h or --help called, exit right now # -h or --help called, exit right now
exit(0) exit(0)
@ -60,7 +60,7 @@ except:
print "ERROR: cannot parsing the arguments" print "ERROR: cannot parsing the arguments"
exit(1) exit(1)
# #
# Main program # Main program
# #
@ -106,26 +106,26 @@ try:
fh = MyTimedRotatingFileHandler.MyTimedRotatingFileHandler(globals.log_path+"boswatch.log", "midnight", interval=1, backupCount=999) fh = MyTimedRotatingFileHandler.MyTimedRotatingFileHandler(globals.log_path+"boswatch.log", "midnight", interval=1, backupCount=999)
# Starts with log level >= Debug # Starts with log level >= Debug
# will be changed with config.ini-param later # will be changed with config.ini-param later
fh.setLevel(logging.DEBUG) fh.setLevel(logging.DEBUG)
fh.setFormatter(formatter) fh.setFormatter(formatter)
myLogger.addHandler(fh) myLogger.addHandler(fh)
# create a display logger # create a display logger
ch = logging.StreamHandler() ch = logging.StreamHandler()
# log level for display: Default: info # log level for display: Default: info
if args.verbose: if args.verbose:
ch.setLevel(logging.DEBUG) ch.setLevel(logging.DEBUG)
elif args.quiet: elif args.quiet:
ch.setLevel(logging.CRITICAL) ch.setLevel(logging.CRITICAL)
else: else:
ch.setLevel(logging.INFO) ch.setLevel(logging.INFO)
ch.setFormatter(formatter) ch.setFormatter(formatter)
myLogger.addHandler(ch) myLogger.addHandler(ch)
except: except:
# we couldn't work without logging -> exit # we couldn't work without logging -> exit
print "ERROR: cannot create logger" print "ERROR: cannot create logger"
exit(1) exit(1)
# initialization of the logging was fine, continue... # initialization of the logging was fine, continue...
try: try:
# #
@ -139,29 +139,29 @@ try:
rtl_log.close() rtl_log.close()
mon_log.close() mon_log.close()
logging.debug("BOSWatch has started") logging.debug("BOSWatch has started")
logging.debug("Logfiles cleared") logging.debug("Logfiles cleared")
except: except:
# It's an error, but we could work without that stuff... # It's an error, but we could work without that stuff...
logging.error("cannot clear Logfiles") logging.error("cannot clear Logfiles")
logging.debug("cannot clear Logfiles", exc_info=True) logging.debug("cannot clear Logfiles", exc_info=True)
pass pass
# #
# For debug display/log args # For debug display/log args
# #
try: try:
logging.debug("SW Version: %s",globals.getVers("vers")) logging.debug("SW Version: %s",globals.getVers("vers"))
logging.debug("Build Date: %s",globals.getVers("date")) logging.debug("Build Date: %s",globals.getVers("date"))
logging.debug("BOSWatch given arguments") logging.debug("BOSWatch given arguments")
if args.test: if args.test:
logging.debug(" - Test-Mode!") logging.debug(" - Test-Mode!")
logging.debug(" - Frequency: %s", converter.freqToHz(args.freq)) logging.debug(" - Frequency: %s", converter.freqToHz(args.freq))
logging.debug(" - Device: %s", args.device) logging.debug(" - Device: %s", args.device)
logging.debug(" - PPM Error: %s", args.error) logging.debug(" - PPM Error: %s", args.error)
logging.debug(" - Squelch: %s", args.squelch) logging.debug(" - Squelch: %s", args.squelch)
demodulation = "" demodulation = ""
if "FMS" in args.demod: if "FMS" in args.demod:
demodulation += "-a FMSFSK " demodulation += "-a FMSFSK "
@ -174,18 +174,18 @@ try:
logging.debug(" - Demod: POC512") logging.debug(" - Demod: POC512")
if "POC1200" in args.demod: if "POC1200" in args.demod:
demodulation += "-a POCSAG1200 " demodulation += "-a POCSAG1200 "
logging.debug(" - Demod: POC1200") logging.debug(" - Demod: POC1200")
if "POC2400" in args.demod: if "POC2400" in args.demod:
demodulation += "-a POCSAG2400 " demodulation += "-a POCSAG2400 "
logging.debug(" - Demod: POC2400") logging.debug(" - Demod: POC2400")
logging.debug(" - Use /var/log: %s", args.usevarlog) logging.debug(" - Use /var/log: %s", args.usevarlog)
logging.debug(" - Verbose Mode: %s", args.verbose) logging.debug(" - Verbose Mode: %s", args.verbose)
logging.debug(" - Quiet Mode: %s", args.quiet) logging.debug(" - Quiet Mode: %s", args.quiet)
if not args.quiet: #only if not quiet mode if not args.quiet: #only if not quiet mode
from includes import shellHeader from includes import shellHeader
shellHeader.printHeader(args) shellHeader.printHeader(args)
if args.test: if args.test:
logging.warning("!!! We are in Test-Mode !!!") logging.warning("!!! We are in Test-Mode !!!")
@ -204,7 +204,7 @@ try:
globals.config = ConfigParser.ConfigParser() globals.config = ConfigParser.ConfigParser()
globals.config.read(globals.script_path+"/config/config.ini") globals.config.read(globals.script_path+"/config/config.ini")
# if given loglevel is debug: # if given loglevel is debug:
if globals.config.getint("BOSWatch","loglevel") == 10: if globals.config.getint("BOSWatch","loglevel") == 10:
logging.debug(" - BOSWatch:") logging.debug(" - BOSWatch:")
for key,val in globals.config.items("BOSWatch"): for key,val in globals.config.items("BOSWatch"):
logging.debug(" -- %s = %s", key, val) logging.debug(" -- %s = %s", key, val)
@ -225,8 +225,8 @@ try:
# initialization was fine, continue with main program... # initialization was fine, continue with main program...
try: try:
# #
# Set the loglevel and backupCount of the file handler # Set the loglevel and backupCount of the file handler
# #
logging.debug("set loglevel of fileHandler to: %s",globals.config.getint("BOSWatch","loglevel")) logging.debug("set loglevel of fileHandler to: %s",globals.config.getint("BOSWatch","loglevel"))
fh.setLevel(globals.config.getint("BOSWatch","loglevel")) fh.setLevel(globals.config.getint("BOSWatch","loglevel"))
@ -237,11 +237,11 @@ try:
logging.error("cannot set loglevel of fileHandler") logging.error("cannot set loglevel of fileHandler")
logging.debug("cannot set loglevel of fileHandler", exc_info=True) logging.debug("cannot set loglevel of fileHandler", exc_info=True)
pass pass
# #
# Load plugins # Load plugins
# #
try: try:
from includes import pluginLoader from includes import pluginLoader
pluginLoader.loadPlugins() pluginLoader.loadPlugins()
except: except:
@ -249,11 +249,11 @@ try:
logging.critical("cannot load Plugins") logging.critical("cannot load Plugins")
logging.debug("cannot load Plugins", exc_info=True) logging.debug("cannot load Plugins", exc_info=True)
exit(1) exit(1)
# #
# Load filters # Load filters
# #
try: try:
if globals.config.getboolean("BOSWatch","useRegExFilter"): if globals.config.getboolean("BOSWatch","useRegExFilter"):
from includes import filter from includes import filter
filter.loadFilters() filter.loadFilters()
@ -262,11 +262,11 @@ try:
logging.error("cannot load filters") logging.error("cannot load filters")
logging.debug("cannot load filters", exc_info=True) logging.debug("cannot load filters", exc_info=True)
pass pass
# #
# Load description lists # Load description lists
# #
try: try:
if globals.config.getboolean("FMS","idDescribed") or globals.config.getboolean("ZVEI","idDescribed") or globals.config.getboolean("POC","idDescribed"): if globals.config.getboolean("FMS","idDescribed") or globals.config.getboolean("ZVEI","idDescribed") or globals.config.getboolean("POC","idDescribed"):
from includes import descriptionList from includes import descriptionList
descriptionList.loadDescriptionLists() descriptionList.loadDescriptionLists()
@ -275,11 +275,11 @@ try:
logging.error("cannot load description lists") logging.error("cannot load description lists")
logging.debug("cannot load description lists", exc_info=True) logging.debug("cannot load description lists", exc_info=True)
pass pass
# #
# Start rtl_fm # Start rtl_fm
# #
try: try:
if not args.test: if not args.test:
logging.debug("starting rtl_fm") logging.debug("starting rtl_fm")
command = "" command = ""
@ -317,7 +317,7 @@ try:
stdin=rtl_fm.stdout, stdin=rtl_fm.stdout,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=open(globals.log_path+"multimon.log","a"), stderr=open(globals.log_path+"multimon.log","a"),
shell=False) shell=False)
# multimon-ng doesn't self-destruct, when an error occurs # multimon-ng doesn't self-destruct, when an error occurs
# wait a moment to give the subprocess a chance to write the logfile # wait a moment to give the subprocess a chance to write the logfile
time.sleep(3) time.sleep(3)
@ -331,15 +331,15 @@ try:
exit(1) exit(1)
# multimon-ng started, continue... # multimon-ng started, continue...
logging.debug("start decoding") logging.debug("start decoding")
# #
# Get decoded data from multimon-ng and call BOSWatch-decoder # Get decoded data from multimon-ng and call BOSWatch-decoder
# #
while True: while True:
if not args.test: if not args.test:
decoded = str(multimon_ng.stdout.readline()) #Get line data from multimon stdout decoded = str(multimon_ng.stdout.readline()) #Get line data from multimon stdout
else: else:
# Test-strings only for develop # Test-strings only for develop
#decoded = "ZVEI2: 25832" #decoded = "ZVEI2: 25832"
@ -349,13 +349,13 @@ try:
#decoded = "FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=III(mit NA,ohneSIGNAL)) CRC correct\n'" #decoded = "FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=III(mit NA,ohneSIGNAL)) CRC correct\n'"
#decoded = "FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=IV (mit NA,mit SIGNAL)) CRC correct\n'" #decoded = "FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=IV (mit NA,mit SIGNAL)) CRC correct\n'"
decoded = "POCSAG1200: Address: 1234567 Function: 1 Alpha: Hello World" decoded = "POCSAG1200: Address: 1234567 Function: 1 Alpha: Hello World"
time.sleep(1) time.sleep(1)
from includes import decoder from includes import decoder
decoder.decode(converter.freqToHz(args.freq), decoded) decoder.decode(converter.freqToHz(args.freq), decoded)
except KeyboardInterrupt: except KeyboardInterrupt:
logging.warning("Keyboard Interrupt") logging.warning("Keyboard Interrupt")
except SystemExit: except SystemExit:
# SystemExitException is thrown if daemon was terminated # SystemExitException is thrown if daemon was terminated
logging.warning("SystemExit received") logging.warning("SystemExit received")
@ -367,24 +367,24 @@ finally:
try: try:
logging.debug("BOSWatch shuting down") logging.debug("BOSWatch shuting down")
if multimon_ng and multimon_ng.pid: if multimon_ng and multimon_ng.pid:
logging.debug("terminate multimon-ng (%s)", multimon_ng.pid) logging.debug("terminate multimon-ng (%s)", multimon_ng.pid)
multimon_ng.terminate() multimon_ng.terminate()
multimon_ng.wait() multimon_ng.wait()
logging.debug("multimon-ng terminated") logging.debug("multimon-ng terminated")
if rtl_fm and rtl_fm.pid: if rtl_fm and rtl_fm.pid:
logging.debug("terminate rtl_fm (%s)", rtl_fm.pid) logging.debug("terminate rtl_fm (%s)", rtl_fm.pid)
rtl_fm.terminate() rtl_fm.terminate()
rtl_fm.wait() rtl_fm.wait()
logging.debug("rtl_fm terminated") logging.debug("rtl_fm terminated")
logging.debug("exiting BOSWatch") logging.debug("exiting BOSWatch")
except: except:
logging.warning("failed in clean-up routine") logging.warning("failed in clean-up routine")
logging.debug("failed in clean-up routine", exc_info=True) logging.debug("failed in clean-up routine", exc_info=True)
finally: finally:
# Close Logging # Close Logging
logging.debug("close Logging") logging.debug("close Logging")
logging.info("BOSWatch exit()") logging.info("BOSWatch exit()")
logging.shutdown() logging.shutdown()
fh.close() fh.close()
ch.close() ch.close()

View file

@ -56,11 +56,11 @@ idDescribed = 0
# some very simple filters: # some very simple filters:
# Allow only this RICs (empty: allow all, separator ",") # Allow only this RICs (empty: allow all, separator ",")
# f.e.: allow_ric = 1234566,1234567,1234568 # f.e.: allow_ric = 1234566,1234567,1234568
allow_ric = allow_ric =
# Deny this RICs (empty: allow all, separator ",") # Deny this RICs (empty: allow all, separator ",")
# f.e.: deny_ric = 1234566,1234567,1234568 # f.e.: deny_ric = 1234566,1234567,1234568
deny_ric = deny_ric =
# start and end of an allowed filter range # start and end of an allowed filter range
filter_range_start = 0000000 filter_range_start = 0000000
@ -130,14 +130,14 @@ tablePOC = bos_pocsag
# %TIME% = Time (by script) # %TIME% = Time (by script)
# %DATE% = Date (by script) # %DATE% = Date (by script)
#fms_url = www.google.de?code=%FMS%&stat=%STATUS% #fms_url = www.google.de?code=%FMS%&stat=%STATUS%
fms_url = fms_url =
# %ZVEI% = ZVEI 5-tone Code # %ZVEI% = ZVEI 5-tone Code
# %DESCR% = Description from csv-file # %DESCR% = Description from csv-file
# %TIME% = Time (by script) # %TIME% = Time (by script)
# %DATE% = Date (by script) # %DATE% = Date (by script)
#zvei_url = www.google.de?zvei=%ZVEI% #zvei_url = www.google.de?zvei=%ZVEI%
zvei_url = zvei_url =
# %RIC% = Pocsag RIC # %RIC% = Pocsag RIC
# %FUNC% = Pocsac function/Subric (1-4) # %FUNC% = Pocsac function/Subric (1-4)
@ -148,13 +148,13 @@ zvei_url =
# %TIME% = Time (by script) # %TIME% = Time (by script)
# %DATE% = Date (by script) # %DATE% = Date (by script)
#poc_url = www.google.de?ric=%RIC%&subric=%FUNC%&msg=%MSG% #poc_url = www.google.de?ric=%RIC%&subric=%FUNC%&msg=%MSG%
poc_url = poc_url =
[eMail] [eMail]
# SMTP-Server # SMTP-Server
smtp_server = localhost smtp_server = localhost
# Port of SMTP-Server (default: # Port of SMTP-Server (default:
smtp_port = smtp_port =
# use tls for connection (0|1) # use tls for connection (0|1)
tls = 0 tls = 0
@ -211,8 +211,8 @@ bosmon_port = 80
bosmon_channel = channel bosmon_channel = channel
# Use this, when BosMon has restricted access # Use this, when BosMon has restricted access
bosmon_user = bosmon_user =
bosmon_password = bosmon_password =
[firEmergency] [firEmergency]
@ -234,4 +234,4 @@ port = 8888
[template] [template]
test1 = testString test1 = testString
test2 = 123456 test2 = 123456

View file

@ -7,4 +7,4 @@ fms,description
# #
# !!! DO NOT delete the first line !!! # !!! DO NOT delete the first line !!!
# #
12345678,"FMS testdata" 12345678,"FMS testdata"

Can't render this file because it has a wrong number of fields in line 2.

View file

@ -7,4 +7,4 @@ ric,description
# #
# !!! DO NOT delete the first line !!! # !!! DO NOT delete the first line !!!
# #
1234567,"POCSAG testdata" 1234567,"POCSAG testdata"

Can't render this file because it has a wrong number of fields in line 2.

View file

@ -7,4 +7,4 @@ zvei,description
# #
# !!! DO NOT delete the first line !!! # !!! DO NOT delete the first line !!!
# #
12345,"ZVEI testdata" 12345,"ZVEI testdata"

Can't render this file because it has a wrong number of fields in line 2.

View file

@ -3,7 +3,7 @@
# #
""" """
This Class extended the TimedRotatingFileHandler with the possibility This Class extended the TimedRotatingFileHandler with the possibility
to change the backupCount after initialization. to change the backupCount after initialization.
@author: Jens Herrmann @author: Jens Herrmann
@ -15,4 +15,4 @@ class MyTimedRotatingFileHandler(logging.handlers.TimedRotatingFileHandler):
"""Extended Version of TimedRotatingFileHandler""" """Extended Version of TimedRotatingFileHandler"""
def setBackupCount(self, backupCount): def setBackupCount(self, backupCount):
"""Set/Change backupCount""" """Set/Change backupCount"""
self.backupCount = backupCount self.backupCount = backupCount

View file

@ -30,7 +30,7 @@ def processAlarm(typ,freq,data):
@param data: Contains the parameter @param data: Contains the parameter
@requires: active plugins in pluginList @requires: active plugins in pluginList
@return: nothing @return: nothing
@exception: Exception if Alarm processing itself failed @exception: Exception if Alarm processing itself failed
""" """
@ -41,7 +41,7 @@ def processAlarm(typ,freq,data):
# if enabled use RegEx-filter # if enabled use RegEx-filter
if globals.config.getint("BOSWatch","useRegExFilter"): if globals.config.getint("BOSWatch","useRegExFilter"):
from includes import filter from includes import filter
if filter.checkFilters(typ,data,pluginName,freq): if filter.checkFilters(typ,data,pluginName,freq):
logging.debug("call Plugin: %s", pluginName) logging.debug("call Plugin: %s", pluginName)
try: try:
plugin.run(typ,freq,data) plugin.run(typ,freq,data)
@ -59,4 +59,4 @@ def processAlarm(typ,freq,data):
pass pass
logging.debug("[END ALARM]") logging.debug("[END ALARM]")
except: except:
logging.exception("Error in alarm processing") logging.exception("Error in alarm processing")

View file

@ -5,7 +5,7 @@
Functions for checking the subprocesses rtl_fm and multimon-ng Functions for checking the subprocesses rtl_fm and multimon-ng
Used in boswatch.py at startup and designated for watching-service Used in boswatch.py at startup and designated for watching-service
@author: Jens Herrmann @author: Jens Herrmann
""" """
import logging import logging
@ -32,7 +32,7 @@ def checkRTL():
logging.critical("cannot check rtl_fm.log") logging.critical("cannot check rtl_fm.log")
logging.debug("cannot check rtl_fm.log", exc_info=True) logging.debug("cannot check rtl_fm.log", exc_info=True)
raise raise
def checkMultimon(): def checkMultimon():
""" """
check startup of multimon-ng check startup of multimon-ng
@ -51,4 +51,4 @@ def checkMultimon():
# we couldn't work without multimon-ng # we couldn't work without multimon-ng
logging.critical("cannot check multimon.log") logging.critical("cannot check multimon.log")
logging.debug("cannot check multimon.log", exc_info=True) logging.debug("cannot check multimon.log", exc_info=True)
raise raise

View file

@ -13,10 +13,10 @@ import logging
def freqToHz(freq): def freqToHz(freq):
""" """
gets a frequency and resolve it in Hz gets a frequency and resolve it in Hz
@type freq: string @type freq: string
@param freq: frequency of the SDR Stick @param freq: frequency of the SDR Stick
@return: frequency in Hz @return: frequency in Hz
@exception: Exception if Error by recalc @exception: Exception if Error by recalc
""" """
@ -26,4 +26,4 @@ def freqToHz(freq):
# otherwise you will get the error: an invalid literal for int() with base 10 # otherwise you will get the error: an invalid literal for int() with base 10
return int(float(freq)) return int(float(freq))
except: except:
logging.exception("Error in freqToHz()") logging.exception("Error in freqToHz()")

View file

@ -19,31 +19,31 @@ def decode(freq, decoded):
@param freq: frequency of the SDR Stick @param freq: frequency of the SDR Stick
@type decoded: string @type decoded: string
@param decoded: RAW Information from Multimon-NG @param decoded: RAW Information from Multimon-NG
@return: nothing @return: nothing
@exception: Exception if decoder file call failed @exception: Exception if decoder file call failed
""" """
try: try:
# FMS Decoder Section # FMS Decoder Section
# check FMS: -> check CRC -> validate -> check double alarm -> log # check FMS: -> check CRC -> validate -> check double alarm -> log
if "FMS:" in decoded: if "FMS:" in decoded:
logging.debug("recieved FMS") logging.debug("recieved FMS")
from includes.decoders import fms from includes.decoders import fms
fms.decode(freq, decoded) fms.decode(freq, decoded)
# ZVEI Decoder Section # ZVEI Decoder Section
# check ZVEI: -> validate -> check double alarm -> log # check ZVEI: -> validate -> check double alarm -> log
elif "ZVEI2:" in decoded: elif "ZVEI2:" in decoded:
logging.debug("recieved ZVEI") logging.debug("recieved ZVEI")
from includes.decoders import zvei from includes.decoders import zvei
zvei.decode(freq, decoded) zvei.decode(freq, decoded)
# POCSAG Decoder Section # POCSAG Decoder Section
# check POCSAG -> validate -> check double alarm -> log # check POCSAG -> validate -> check double alarm -> log
elif "POCSAG512:" in decoded or "POCSAG1200:" in decoded or "POCSAG2400:" in decoded: elif "POCSAG512:" in decoded or "POCSAG1200:" in decoded or "POCSAG2400:" in decoded:
logging.debug("recieved POCSAG") logging.debug("recieved POCSAG")
from includes.decoders import poc from includes.decoders import poc
poc.decode(freq, decoded) poc.decode(freq, decoded)
except: except:
logging.exception("cannot start decoder") logging.exception("cannot start decoder")

View file

@ -18,7 +18,7 @@ from includes import doubleFilter # double alarm filter
## ##
# #
# FMS decoder function # FMS decoder function
# validate -> check double alarm -> log # validate -> check double alarm -> log
# #
def decode(freq, decoded): def decode(freq, decoded):
""" """
@ -30,7 +30,7 @@ def decode(freq, decoded):
@param decoded: RAW Information from Multimon-NG @param decoded: RAW Information from Multimon-NG
@requires: Configuration has to be set in the config.ini @requires: Configuration has to be set in the config.ini
@return: nothing @return: nothing
@exception: Exception if FMS decode failed @exception: Exception if FMS decode failed
""" """
@ -42,11 +42,11 @@ def decode(freq, decoded):
fms_direction = decoded[101] # Richtung fms_direction = decoded[101] # Richtung
fms_directionText = decoded[103:110] # Richtung (Text) fms_directionText = decoded[103:110] # Richtung (Text)
fms_tsi = decoded[114:117] # Taktische Kruzinformation fms_tsi = decoded[114:117] # Taktische Kruzinformation
if "CRC correct" in decoded: #check CRC is correct if "CRC correct" in decoded: #check CRC is correct
fms_id = fms_service+fms_country+fms_location+fms_vehicle+fms_status+fms_direction # build FMS id fms_id = fms_service+fms_country+fms_location+fms_vehicle+fms_status+fms_direction # build FMS id
# if FMS is valid # if FMS is valid
if re.search("[0-9a-f]{8}[0-9a-f]{1}[01]{1}", fms_id): if re.search("[0-9a-f]{8}[0-9a-f]{1}[01]{1}", fms_id):
# check for double alarm # check for double alarm
if doubleFilter.checkID("FMS", fms_id): if doubleFilter.checkID("FMS", fms_id):
logging.info("FMS:%s Status:%s Richtung:%s TSI:%s", fms_id[0:8], fms_status, fms_direction, fms_tsi) logging.info("FMS:%s Status:%s Richtung:%s TSI:%s", fms_id[0:8], fms_status, fms_direction, fms_tsi)
@ -66,6 +66,6 @@ def decode(freq, decoded):
# in every time save old data for double alarm # in every time save old data for double alarm
doubleFilter.newEntry(fms_id) doubleFilter.newEntry(fms_id)
else: else:
logging.warning("No valid FMS: %s", fms_id) logging.warning("No valid FMS: %s", fms_id)
else: else:
logging.warning("FMS CRC incorrect") logging.warning("FMS CRC incorrect")

View file

@ -28,11 +28,11 @@ def isAllowed(poc_id):
@param poc_id: POCSAG Ric @param poc_id: POCSAG Ric
@requires: Configuration has to be set in the config.ini @requires: Configuration has to be set in the config.ini
@return: True if the Ric is allowed, other False @return: True if the Ric is allowed, other False
@exception: none @exception: none
""" """
# 1.) If allowed RICs is set, only they will path, # 1.) If allowed RICs is set, only they will path,
# If RIC is the right one return True, else False # If RIC is the right one return True, else False
if globals.config.get("POC", "allow_ric"): if globals.config.get("POC", "allow_ric"):
if poc_id in globals.config.get("POC", "allow_ric"): if poc_id in globals.config.get("POC", "allow_ric"):
@ -55,7 +55,7 @@ def isAllowed(poc_id):
return True return True
## ##
# #
# POCSAG decoder function # POCSAG decoder function
# validate -> check double alarm -> log # validate -> check double alarm -> log
# #
@ -69,38 +69,38 @@ def decode(freq, decoded):
@param decoded: RAW Information from Multimon-NG @param decoded: RAW Information from Multimon-NG
@requires: Configuration has to be set in the config.ini @requires: Configuration has to be set in the config.ini
@return: nothing @return: nothing
@exception: Exception if POCSAG decode failed @exception: Exception if POCSAG decode failed
""" """
bitrate = 0 bitrate = 0
if "POCSAG512:" in decoded: if "POCSAG512:" in decoded:
bitrate = 512 bitrate = 512
poc_id = decoded[20:27].replace(" ", "").zfill(7) poc_id = decoded[20:27].replace(" ", "").zfill(7)
poc_sub = decoded[39].replace("3", "4").replace("2", "3").replace("1", "2").replace("0", "1") poc_sub = decoded[39].replace("3", "4").replace("2", "3").replace("1", "2").replace("0", "1")
elif "POCSAG1200:" in decoded: elif "POCSAG1200:" in decoded:
bitrate = 1200 bitrate = 1200
poc_id = decoded[21:28].replace(" ", "").zfill(7) poc_id = decoded[21:28].replace(" ", "").zfill(7)
poc_sub = decoded[40].replace("3", "4").replace("2", "3").replace("1", "2").replace("0", "1") poc_sub = decoded[40].replace("3", "4").replace("2", "3").replace("1", "2").replace("0", "1")
elif "POCSAG2400:" in decoded: elif "POCSAG2400:" in decoded:
bitrate = 2400 bitrate = 2400
poc_id = decoded[21:28].replace(" ", "").zfill(7) poc_id = decoded[21:28].replace(" ", "").zfill(7)
poc_sub = decoded[40].replace("3", "4").replace("2", "3").replace("1", "2").replace("0", "1") poc_sub = decoded[40].replace("3", "4").replace("2", "3").replace("1", "2").replace("0", "1")
if bitrate is 0: if bitrate is 0:
logging.warning("POCSAG Bitrate not found") logging.warning("POCSAG Bitrate not found")
logging.debug(" - (%s)", decoded) logging.debug(" - (%s)", decoded)
else: else:
logging.debug("POCSAG Bitrate: %s", bitrate) logging.debug("POCSAG Bitrate: %s", bitrate)
if "Alpha:" in decoded: #check if there is a text message if "Alpha:" in decoded: #check if there is a text message
poc_text = decoded.split('Alpha: ')[1].strip().rstrip('<EOT>').strip() poc_text = decoded.split('Alpha: ')[1].strip().rstrip('<EOT>').strip()
else: else:
poc_text = "" poc_text = ""
if re.search("[0-9]{7}", poc_id): #if POC is valid if re.search("[0-9]{7}", poc_id): #if POC is valid
if isAllowed(poc_id): if isAllowed(poc_id):
# check for double alarm # check for double alarm
@ -126,4 +126,4 @@ def decode(freq, decoded):
else: else:
logging.debug("POCSAG%s: %s is not allowed", bitrate, poc_id) logging.debug("POCSAG%s: %s is not allowed", bitrate, poc_id)
else: else:
logging.warning("No valid POCSAG%s RIC: %s", bitrate, poc_id) logging.warning("No valid POCSAG%s RIC: %s", bitrate, poc_id)

View file

@ -25,7 +25,7 @@ def removeF(zvei):
@type zvei: string @type zvei: string
@param zvei: ZVEI Information @param zvei: ZVEI Information
@return: ZVEI without F @return: ZVEI without F
@exception: none @exception: none
""" """
@ -40,7 +40,7 @@ def removeF(zvei):
## ##
# #
# ZVEI decoder function # ZVEI decoder function
# validate -> check double alarm -> log # validate -> check double alarm -> log
# #
def decode(freq, decoded): def decode(freq, decoded):
""" """
@ -52,11 +52,11 @@ def decode(freq, decoded):
@param decoded: RAW Information from Multimon-NG @param decoded: RAW Information from Multimon-NG
@requires: Configuration has to be set in the config.ini @requires: Configuration has to be set in the config.ini
@return: nothing @return: nothing
@exception: Exception if ZVEI decode failed @exception: Exception if ZVEI decode failed
""" """
zvei_id = decoded[7:12] # ZVEI Code zvei_id = decoded[7:12] # ZVEI Code
zvei_id = removeF(zvei_id) # resolve F zvei_id = removeF(zvei_id) # resolve F
if re.search("[0-9]{5}", zvei_id): # if ZVEI is valid if re.search("[0-9]{5}", zvei_id): # if ZVEI is valid
# check for double alarm # check for double alarm
@ -78,4 +78,4 @@ def decode(freq, decoded):
# in every time save old data for double alarm # in every time save old data for double alarm
doubleFilter.newEntry(zvei_id) doubleFilter.newEntry(zvei_id)
else: else:
logging.warning("No valid ZVEI: %s", zvei_id) logging.warning("No valid ZVEI: %s", zvei_id)

View file

@ -44,7 +44,7 @@ def loadCSV(typ, idField):
raise raise
return resultList; return resultList;
## ##
# #
# call this for loading the description lists # call this for loading the description lists
@ -62,7 +62,7 @@ def loadDescriptionLists():
if globals.config.getint("FMS", "idDescribed"): if globals.config.getint("FMS", "idDescribed"):
logging.debug("- load FMS description list") logging.debug("- load FMS description list")
globals.fmsDescribtionList = loadCSV("fms", "fms") globals.fmsDescribtionList = loadCSV("fms", "fms")
if globals.config.getint("ZVEI", "idDescribed"): if globals.config.getint("ZVEI", "idDescribed"):
logging.debug("- load ZVEI description list") logging.debug("- load ZVEI description list")
globals.zveiDescribtionList = loadCSV("zvei", "zvei") globals.zveiDescribtionList = loadCSV("zvei", "zvei")
@ -70,17 +70,17 @@ def loadDescriptionLists():
if globals.config.getint("POC", "idDescribed"): if globals.config.getint("POC", "idDescribed"):
logging.debug("- load pocsag description list") logging.debug("- load pocsag description list")
globals.ricDescribtionList = loadCSV("poc", "ric") globals.ricDescribtionList = loadCSV("poc", "ric")
except: except:
logging.error("cannot load description lists") logging.error("cannot load description lists")
logging.debug("cannot load description lists", exc_info=True) logging.debug("cannot load description lists", exc_info=True)
pass pass
## ##
# #
# public function for getting a description # public function for getting a description
# #
def getDescription(typ, id): def getDescription(typ, id):
""" """
Get description for id. Get description for id.
@ -98,17 +98,17 @@ def getDescription(typ, id):
elif typ == "POC": elif typ == "POC":
resultStr = globals.ricDescribtionList[id] resultStr = globals.ricDescribtionList[id]
else: else:
logging.warning("Invalid Typ: %s", typ) logging.warning("Invalid Typ: %s", typ)
except KeyError: except KeyError:
# will be thrown when there is no description for the id # will be thrown when there is no description for the id
# -> nothing to do... # -> nothing to do...
pass pass
except: except:
logging.error("Error during look up description lists") logging.error("Error during look up description lists")
logging.debug("Error during look up description lists", exc_info=True) logging.debug("Error during look up description lists", exc_info=True)
pass pass
logging.debug(" - result for %s: %s", id, resultStr) logging.debug(" - result for %s: %s", id, resultStr)
return resultStr return resultStr

View file

@ -23,20 +23,20 @@ from includes import globals # Global variables
def checkID(typ, id, msg=""): def checkID(typ, id, msg=""):
""" """
check if id was called in the last x sec and n entries check if id was called in the last x sec and n entries
@requires: Configuration has to be set in the config.ini @requires: Configuration has to be set in the config.ini
@return: True if check was OK @return: True if check was OK
@return: False if double was found @return: False if double was found
""" """
timestamp = int(time.time()) # Get Timestamp timestamp = int(time.time()) # Get Timestamp
for i in range(len(globals.doubleList)): for i in range(len(globals.doubleList)):
(xID, xTimestamp, xMsg) = globals.doubleList[i] (xID, xTimestamp, xMsg) = globals.doubleList[i]
# given ID found? # given ID found?
# return False if the first entry in double_ignore_time is found, we will not check for younger ones... # return False if the first entry in double_ignore_time is found, we will not check for younger ones...
if id == xID and timestamp < xTimestamp + globals.config.getint("BOSWatch", "doubleFilter_ignore_time"): if id == xID and timestamp < xTimestamp + globals.config.getint("BOSWatch", "doubleFilter_ignore_time"):
# if wanted, we have to check the msg additional # if wanted, we have to check the msg additional
if "POC" in typ and globals.config.getint("BOSWatch", "doubleFilter_check_msg"): if "POC" in typ and globals.config.getint("BOSWatch", "doubleFilter_check_msg"):
# if msg is a substring of xMsg we found a double # if msg is a substring of xMsg we found a double
if msg in xMsg: if msg in xMsg:
@ -46,20 +46,20 @@ def checkID(typ, id, msg=""):
logging.info("%s double alarm (id): %s within %s second(s)", typ, xID, timestamp-xTimestamp) logging.info("%s double alarm (id): %s within %s second(s)", typ, xID, timestamp-xTimestamp)
return False return False
return True return True
def newEntry(id, msg = ""): def newEntry(id, msg = ""):
""" """
new entry in double alarm list new entry in double alarm list
@return: nothing @return: nothing
""" """
timestamp = int(time.time()) # Get Timestamp timestamp = int(time.time()) # Get Timestamp
globals.doubleList.append((id, timestamp, msg)) globals.doubleList.append((id, timestamp, msg))
logging.debug("Added %s to doubleList", id) logging.debug("Added %s to doubleList", id)
# now check if list has more than n entries: # now check if list has more than n entries:
if len(globals.doubleList) > globals.config.getint("BOSWatch", "doubleFilter_ignore_entries"): if len(globals.doubleList) > globals.config.getint("BOSWatch", "doubleFilter_ignore_entries"):
# we have to kill the oldest one # we have to kill the oldest one
globals.doubleList.pop(0) globals.doubleList.pop(0)

View file

@ -23,7 +23,7 @@ def loadFilters():
load all filters from the config.ini into globals.filterList load all filters from the config.ini into globals.filterList
@requires: Configuration has to be set in the config.ini @requires: Configuration has to be set in the config.ini
@return: nothing @return: nothing
""" """
try: try:
@ -32,11 +32,11 @@ def loadFilters():
for key,val in globals.config.items("Filters"): for key,val in globals.config.items("Filters"):
logging.debug(" - %s = %s", key, val) logging.debug(" - %s = %s", key, val)
filter = val.split(";") filter = val.split(";")
# resolve the * for freqToHz() # resolve the * for freqToHz()
if not filter[3] == "*": if not filter[3] == "*":
filter[3] = converter.freqToHz(filter[3]) filter[3] = converter.freqToHz(filter[3])
# insert splitet data into globals.filterList # insert splitet data into globals.filterList
globals.filterList.append({"name": key, "typ": filter[0], "dataField": filter[1], "plugin": filter[2], "freq": filter[3], "regex": filter[4]}) globals.filterList.append({"name": key, "typ": filter[0], "dataField": filter[1], "plugin": filter[2], "freq": filter[3], "regex": filter[4]})
except: except:
@ -44,12 +44,12 @@ def loadFilters():
logging.debug("cannot read config file", exc_info=True) logging.debug("cannot read config file", exc_info=True)
return return
def checkFilters(typ,data,plugin,freq): def checkFilters(typ,data,plugin,freq):
""" """
Check the Typ/Plugin combination with the RegEX filter Check the Typ/Plugin combination with the RegEX filter
If no filter for the combination is found, function returns True. If no filter for the combination is found, function returns True.
@type typ: string (FMS|ZVEI|POC) @type typ: string (FMS|ZVEI|POC)
@param typ: Typ of the dataset @param typ: Typ of the dataset
@type data: map of data (structure see interface.txt) @type data: map of data (structure see interface.txt)
@ -58,14 +58,14 @@ def checkFilters(typ,data,plugin,freq):
@param plugin: Name of the plugin to checked @param plugin: Name of the plugin to checked
@type freq: string @type freq: string
@param freq: frequency of the SDR Stick @param freq: frequency of the SDR Stick
@requires: all filters in the filterList @requires: all filters in the filterList
@return: nothing @return: nothing
""" """
try: try:
logging.debug("search Filter for %s to %s at %s Hz", typ, plugin, freq) logging.debug("search Filter for %s to %s at %s Hz", typ, plugin, freq)
foundFilter = False foundFilter = False
# go to all filter in globals.filterList # go to all filter in globals.filterList
for i in globals.filterList: for i in globals.filterList:
@ -79,16 +79,16 @@ def checkFilters(typ,data,plugin,freq):
return True return True
else: else:
logging.debug("Filter not passed: %s", i["name"]) logging.debug("Filter not passed: %s", i["name"])
if foundFilter: if foundFilter:
logging.debug("no Filter passed") logging.debug("no Filter passed")
return False return False
else: else:
logging.debug("no Filter found") logging.debug("no Filter found")
return True return True
except: except:
logging.error("Error in filter checking") logging.error("Error in filter checking")
logging.debug("Error in filter checking", exc_info=True) logging.debug("Error in filter checking", exc_info=True)
# something goes wrong, data will path # something goes wrong, data will path
return True return True

View file

@ -33,4 +33,4 @@ def getVers(mode="vers"):
if mode == "vers": if mode == "vers":
return "2.0-RC" return "2.0-RC"
elif mode == "date": elif mode == "date":
return " 2015/07/02" return " 2015/07/02"

View file

@ -17,15 +17,15 @@ def curtime(format="%d.%m.%Y %H:%M:%S"):
""" """
Returns formated date and/or time Returns formated date and/or time
see: https://docs.python.org/2/library/time.html#time.strftime see: https://docs.python.org/2/library/time.html#time.strftime
@type format: string @type format: string
@param format: Python time Format-String @param format: Python time Format-String
@return: Formated Time and/or Date @return: Formated Time and/or Date
@exception: Exception if Error in format @exception: Exception if Error in format
""" """
try: try:
return time.strftime(format) return time.strftime(format)
except: except:
logging.warning("error in time-format-string") logging.warning("error in time-format-string")
logging.debug("error in time-format-string", exc_info=True) logging.debug("error in time-format-string", exc_info=True)

View file

@ -34,7 +34,7 @@ def loadPlugins():
logging.debug("call %s.onLoad()", i["name"]) logging.debug("call %s.onLoad()", i["name"])
plugin.onLoad() plugin.onLoad()
# Add it to globals.pluginList # Add it to globals.pluginList
globals.pluginList[i["name"]] = plugin globals.pluginList[i["name"]] = plugin
except: except:
# call next plugin, if one has thrown an exception # call next plugin, if one has thrown an exception
logging.error("error calling %s.onLoad()", i["name"]) logging.error("error calling %s.onLoad()", i["name"])
@ -60,13 +60,13 @@ def getPlugins():
# Go to all Folders in the Plugin-Dir # Go to all Folders in the Plugin-Dir
for i in os.listdir(PluginFolder): for i in os.listdir(PluginFolder):
location = os.path.join(PluginFolder, i) location = os.path.join(PluginFolder, i)
# Skip if Path.isdir() or no File DIR_NAME.py is found # Skip if Path.isdir() or no File DIR_NAME.py is found
if not os.path.isdir(location) or not i + ".py" in os.listdir(location): if not os.path.isdir(location) or not i + ".py" in os.listdir(location):
continue continue
# is the plugin enabled in the config-file? # is the plugin enabled in the config-file?
try: try:
if globals.config.getint("Plugins", i): if globals.config.getint("Plugins", i):
info = imp.find_module(i, [location]) info = imp.find_module(i, [location])
plugins.append({"name": i, "info": info}) plugins.append({"name": i, "info": info})
@ -74,8 +74,8 @@ def getPlugins():
else: else:
logging.debug("Plugin [DISABLED] %s ", i) logging.debug("Plugin [DISABLED] %s ", i)
# no entry for plugin found in config-file # no entry for plugin found in config-file
except NoOptionError: except NoOptionError:
logging.warning("Plugin [NO CONF ] %s", i) logging.warning("Plugin [NO CONF ] %s", i)
pass pass
except: except:
logging.error("Error during Plugin search") logging.error("Error during Plugin search")
@ -91,8 +91,8 @@ def loadPlugin(plugin):
@type plugin: Plugin Data @type plugin: Plugin Data
@param plugin: Contains the information to import a Plugin @param plugin: Contains the information to import a Plugin
@return: nothing @return: nothing
@exception: Exception if Plugin import failed @exception: Exception if Plugin import failed
""" """
@ -102,4 +102,4 @@ def loadPlugin(plugin):
except: except:
logging.error("cannot load Plugin: %s", plugin["name"]) logging.error("cannot load Plugin: %s", plugin["name"])
logging.debug("cannot load Plugin: %s", plugin["name"], exc_info=True) logging.debug("cannot load Plugin: %s", plugin["name"], exc_info=True)
raise raise

View file

@ -18,18 +18,18 @@ def printHeader(args):
@type args: Array @type args: Array
@param args: All given arguments from argsparser @param args: All given arguments from argsparser
@return: nothing @return: nothing
""" """
try: try:
print " ____ ____ ______ __ __ __ " print " ____ ____ ______ __ __ __ "
print " / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ " print " / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ "
print " / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ " print " / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ "
print " / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / " print " / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / "
print " /_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ " print " /_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ "
print " German BOS Information Script " print " German BOS Information Script "
print " by Bastian Schroll, Jens Herrmann " print " by Bastian Schroll, Jens Herrmann "
print "" print ""
print "SW Version: "+globals.getVers("vers") print "SW Version: "+globals.getVers("vers")
print "Build Date: "+globals.getVers("date") print "Build Date: "+globals.getVers("date")
print "" print ""
@ -41,19 +41,19 @@ def printHeader(args):
if "FMS" in args.demod: if "FMS" in args.demod:
print "- FMS" print "- FMS"
if "ZVEI" in args.demod: if "ZVEI" in args.demod:
print "- ZVEI" print "- ZVEI"
if "POC512" in args.demod: if "POC512" in args.demod:
print "- POC512" print "- POC512"
if "POC1200" in args.demod: if "POC1200" in args.demod:
print "- POC1200" print "- POC1200"
if "POC2400" in args.demod: if "POC2400" in args.demod:
print "- POC2400" print "- POC2400"
print "Squelch: "+str(args.squelch) print "Squelch: "+str(args.squelch)
if args.verbose: if args.verbose:
print "Verbose Mode!" print "Verbose Mode!"
if args.test: if args.test:
print "Test Mode!" print "Test Mode!"
print "" print ""
except: except:
logging.error("cannot display shell header") logging.error("cannot display shell header")
logging.debug("cannot display shell header", exc_info=True) logging.debug("cannot display shell header", exc_info=True)

View file

@ -4,7 +4,7 @@
""" """
TERM-Handler for use script as a daemon TERM-Handler for use script as a daemon
In order for the Python program to exit gracefully when the TERM signal is received, In order for the Python program to exit gracefully when the TERM signal is received,
it must have a function that exits the program when signal.SIGTERM is received. it must have a function that exits the program when signal.SIGTERM is received.
@author: Jens Herrmann @author: Jens Herrmann
@ -19,7 +19,7 @@ def sigterm_handler(_signo, _stack_frame):
TERM-Handler for use script as a daemon TERM-Handler for use script as a daemon
@type _signo: signalnum @type _signo: signalnum
@param _signo: signal number @param _signo: signal number
@type _stack_frame: frame object @type _stack_frame: frame object
@param _stack_frame: current stack frame @param _stack_frame: current stack frame
@ -29,4 +29,4 @@ def sigterm_handler(_signo, _stack_frame):
sys.exit(0) sys.exit(0)
# Set the handler for signal to the function handler. # Set the handler for signal to the function handler.
signal.signal(signal.SIGTERM, sigterm_handler) signal.signal(signal.SIGTERM, sigterm_handler)

View file

@ -1,20 +1,20 @@
#!/bin/sh #!/bin/sh
tput clear tput clear
tput civis tput civis
echo " ____ ____ ______ __ __ __ " echo " ____ ____ ______ __ __ __ "
echo " / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ " echo " / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ "
echo " / __ / / / /\__ \| | /| / / __ / __/ ___/ __ \ " echo " / __ / / / /\__ \| | /| / / __ / __/ ___/ __ \ "
echo " / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / " echo " / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / "
echo " /_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ " echo " /_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ "
echo " German BOS Information Script " echo " German BOS Information Script "
echo " by Bastian Schroll " echo " by Bastian Schroll "
echo "" echo ""
echo "This may take a several minutes... Don't panic!" echo "This may take a several minutes... Don't panic!"
echo "" echo ""
echo "Caution, script don't install a Webserver with PHP and MySQL" echo "Caution, script don't install a Webserver with PHP and MySQL"
echo "So you have to make up manually if you want to use MySQL support" echo "So you have to make up manually if you want to use MySQL support"
mkdir -p ~/boswatch/install mkdir -p ~/boswatch/install
tput cup 13 15 tput cup 13 15
echo "[ 1/10] [#---------]" echo "[ 1/10] [#---------]"
@ -32,7 +32,7 @@ tput cup 13 15
echo "[ 3/10] [###-------]" echo "[ 3/10] [###-------]"
tput cup 15 5 tput cup 15 5
echo "-> download rtl_fm......................" echo "-> download rtl_fm......................"
cd ~/boswatch/install cd ~/boswatch/install
git clone git://git.osmocom.org/rtl-sdr.git >> ~/boswatch/install/setup_log.txt 2>&1 git clone git://git.osmocom.org/rtl-sdr.git >> ~/boswatch/install/setup_log.txt 2>&1
cd rtl-sdr/ cd rtl-sdr/
@ -50,7 +50,7 @@ tput cup 13 15
echo "[ 5/10] [#####-----]" echo "[ 5/10] [#####-----]"
tput cup 15 5 tput cup 15 5
echo "-> download multimon-ng................" echo "-> download multimon-ng................"
cd ~/boswatch/install cd ~/boswatch/install
git clone https://github.com/EliasOenal/multimonNG.git >> ~/boswatch/install/setup_log.txt 2>&1 git clone https://github.com/EliasOenal/multimonNG.git >> ~/boswatch/install/setup_log.txt 2>&1
cd multimonNG/ cd multimonNG/
@ -68,7 +68,7 @@ tput cup 13 15
echo "[ 7/10] [#######---]" echo "[ 7/10] [#######---]"
tput cup 15 5 tput cup 15 5
echo "-> download MySQL Connector for Python." echo "-> download MySQL Connector for Python."
cd ~/boswatch/install cd ~/boswatch/install
wget "http://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-1.0.9.tar.gz/from/http://cdn.mysql.com/" -O mysql-connector.tar >> ~/boswatch/install/setup_log.txt 2>&1 wget "http://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-1.0.9.tar.gz/from/http://cdn.mysql.com/" -O mysql-connector.tar >> ~/boswatch/install/setup_log.txt 2>&1
tar xfv mysql-connector.tar >> ~/boswatch/install/setup_log.txt 2>&1 tar xfv mysql-connector.tar >> ~/boswatch/install/setup_log.txt 2>&1
cd mysql-connector-python* cd mysql-connector-python*
@ -97,4 +97,4 @@ echo "# BOSWatch - blacklist the DVB drivers to avoid conflict with the SDR driv
tput cup 17 1 tput cup 17 1
echo "BOSWatch are now installed in ~/boswatch/" echo "BOSWatch are now installed in ~/boswatch/"
echo "Install ready!" echo "Install ready!"

View file

@ -30,7 +30,7 @@ def onLoad():
this onLoad() routine is called one time for initialize the plugin this onLoad() routine is called one time for initialize the plugin
@requires: nothing @requires: nothing
@return: nothing @return: nothing
""" """
# nothing to do for this plugin # nothing to do for this plugin
@ -50,7 +50,7 @@ def bosMonRequest(httprequest, params, headers):
@param params: Contains the parameter for transfer to BosMon. @param params: Contains the parameter for transfer to BosMon.
@type headers: map @type headers: map
@param headers: The headers argument should be a mapping of extra HTTP headers to send with the request. @param headers: The headers argument should be a mapping of extra HTTP headers to send with the request.
@return: nothing @return: nothing
@exception: Exception if HTTP-Request failed @exception: Exception if HTTP-Request failed
""" """
@ -63,8 +63,8 @@ def bosMonRequest(httprequest, params, headers):
logging.error("request to BosMon failed") logging.error("request to BosMon failed")
logging.debug("request to BosMon failed", exc_info=True) logging.debug("request to BosMon failed", exc_info=True)
raise raise
else: else:
# #
# check HTTP-Response # check HTTP-Response
# #
httpresponse = httprequest.getresponse() httpresponse = httprequest.getresponse()
@ -82,7 +82,7 @@ def run(typ,freq,data):
""" """
This function is the implementation of the BosMon-Plugin. This function is the implementation of the BosMon-Plugin.
It will send the data to an BosMon-Instance via http It will send the data to an BosMon-Instance via http
The configuration for the BosMon-Connection is set in the config.ini. The configuration for the BosMon-Connection is set in the config.ini.
If an user is set, the HTTP-Request is authenticatet. If an user is set, the HTTP-Request is authenticatet.
@ -94,7 +94,7 @@ def run(typ,freq,data):
@keyword freq: frequency is not used in this plugin @keyword freq: frequency is not used in this plugin
@requires: BosMon-Configuration has to be set in the config.ini @requires: BosMon-Configuration has to be set in the config.ini
@return: nothing @return: nothing
""" """
try: try:
@ -140,8 +140,8 @@ def run(typ,freq,data):
logging.debug("Start FMS to BosMon") logging.debug("Start FMS to BosMon")
try: try:
# BosMon-Telegramin expected assembly group, direction and tsi in one field # BosMon-Telegramin expected assembly group, direction and tsi in one field
# structure (binary as hex in base10): # structure (binary as hex in base10):
# Byte 1: assembly group; Byte 2: Direction; Byte 3+4: tactic short info # Byte 1: assembly group; Byte 2: Direction; Byte 3+4: tactic short info
info = 0 info = 0
# assembly group: # assembly group:
info = info + 1 # + b0001 (Assumption: is in every time 1 (no output from multimon-ng)) info = info + 1 # + b0001 (Assumption: is in every time 1 (no output from multimon-ng))
@ -156,10 +156,10 @@ def run(typ,freq,data):
elif "II" in data["tsi"]: elif "II" in data["tsi"]:
info = info + 4 # + b0100 info = info + 4 # + b0100
# "I" is nothing to do + b0000 # "I" is nothing to do + b0000
params = urllib.urlencode({'type':'fms', 'address':data["fms"], 'status':data["status"], 'info':info, 'flags':'0'}) params = urllib.urlencode({'type':'fms', 'address':data["fms"], 'status':data["status"], 'info':info, 'flags':'0'})
logging.debug(" - Params: %s", params) logging.debug(" - Params: %s", params)
# dispatch the BosMon-request # dispatch the BosMon-request
bosMonRequest(httprequest, params, headers) bosMonRequest(httprequest, params, headers)
except: except:
logging.error("FMS to BosMon failed") logging.error("FMS to BosMon failed")
@ -171,7 +171,7 @@ def run(typ,freq,data):
try: try:
params = urllib.urlencode({'type':'zvei', 'address':data["zvei"], 'flags':'0'}) params = urllib.urlencode({'type':'zvei', 'address':data["zvei"], 'flags':'0'})
logging.debug(" - Params: %s", params) logging.debug(" - Params: %s", params)
# dispatch the BosMon-request # dispatch the BosMon-request
bosMonRequest(httprequest, params, headers) bosMonRequest(httprequest, params, headers)
except: except:
logging.error("ZVEI to BosMon failed") logging.error("ZVEI to BosMon failed")
@ -184,24 +184,24 @@ def run(typ,freq,data):
# BosMon-Telegramin expected "a-d" as RIC-sub/function # BosMon-Telegramin expected "a-d" as RIC-sub/function
params = urllib.urlencode({'type':'pocsag', 'address':data["ric"], 'flags':'0', 'function':data["functionChar"], 'message':data["msg"]}) params = urllib.urlencode({'type':'pocsag', 'address':data["ric"], 'flags':'0', 'function':data["functionChar"], 'message':data["msg"]})
logging.debug(" - Params: %s", params) logging.debug(" - Params: %s", params)
# dispatch the BosMon-request # dispatch the BosMon-request
bosMonRequest(httprequest, params, headers) bosMonRequest(httprequest, params, headers)
except: except:
logging.error("POC to BosMon failed") logging.error("POC to BosMon failed")
logging.debug("POC to BosMon failed", exc_info=True) logging.debug("POC to BosMon failed", exc_info=True)
return return
else: else:
logging.warning("Invalid Typ: %s", typ) logging.warning("Invalid Typ: %s", typ)
finally: finally:
logging.debug("close BosMon-Connection") logging.debug("close BosMon-Connection")
try: try:
httprequest.close() httprequest.close()
except: except:
pass pass
except: except:
# something very mysterious # something very mysterious
logging.error("unknown error") logging.error("unknown error")
logging.debug("unknown error", exc_info=True) logging.debug("unknown error", exc_info=True)

View file

@ -29,12 +29,12 @@ def onLoad():
this onLoad() routine is called one time for initialize the plugin this onLoad() routine is called one time for initialize the plugin
@requires: nothing @requires: nothing
@return: nothing @return: nothing
""" """
# nothing to do for this plugin # nothing to do for this plugin
return return
## ##
# #
@ -45,7 +45,7 @@ def run(typ,freq,data):
""" """
This function is the implementation of the MySQL-Plugin. This function is the implementation of the MySQL-Plugin.
It will store the data to an MySQL database It will store the data to an MySQL database
The configuration for the MySQL-Connection is set in the config.ini. The configuration for the MySQL-Connection is set in the config.ini.
For DB- and tablestructure see boswatch.sql For DB- and tablestructure see boswatch.sql
@ -58,7 +58,7 @@ def run(typ,freq,data):
@requires: MySQL-Configuration has to be set in the config.ini @requires: MySQL-Configuration has to be set in the config.ini
@requires: Created Database/Tables, see boswatch.sql @requires: Created Database/Tables, see boswatch.sql
@return: nothing @return: nothing
""" """
try: try:
@ -73,7 +73,7 @@ def run(typ,freq,data):
logging.error("cannot read config file") logging.error("cannot read config file")
logging.debug("cannot read config file", exc_info=True) logging.debug("cannot read config file", exc_info=True)
else: # Without config, plugin couldn't work else: # Without config, plugin couldn't work
try: try:
# #
# Connect to MySQL # Connect to MySQL
@ -83,38 +83,38 @@ def run(typ,freq,data):
cursor = connection.cursor() cursor = connection.cursor()
except: except:
logging.error("cannot connect to MySQL") logging.error("cannot connect to MySQL")
logging.debug("cannot connect to MySQL", exc_info=True) logging.debug("cannot connect to MySQL", exc_info=True)
else: # Without connection, plugin couldn't work else: # Without connection, plugin couldn't work
try: try:
# #
# Create and execute SQL-statement # Create and execute SQL-statement
# #
logging.debug("Insert %s", typ) logging.debug("Insert %s", typ)
if typ == "FMS": if typ == "FMS":
cursor.execute("INSERT INTO "+globals.config.get("MySQL","tableFMS")+" (time,fms,status,direction,directionText,tsi,description) VALUES (NOW(),%s,%s,%s,%s,%s,%s)",(data["fms"],data["status"],data["direction"],data["directionText"],data["tsi"],data["description"])) cursor.execute("INSERT INTO "+globals.config.get("MySQL","tableFMS")+" (time,fms,status,direction,directionText,tsi,description) VALUES (NOW(),%s,%s,%s,%s,%s,%s)",(data["fms"],data["status"],data["direction"],data["directionText"],data["tsi"],data["description"]))
elif typ == "ZVEI": elif typ == "ZVEI":
cursor.execute("INSERT INTO "+globals.config.get("MySQL","tableZVEI")+" (time,zvei,description) VALUES (NOW(),%s,%s)",(data["zvei"],data["description"])) cursor.execute("INSERT INTO "+globals.config.get("MySQL","tableZVEI")+" (time,zvei,description) VALUES (NOW(),%s,%s)",(data["zvei"],data["description"]))
elif typ == "POC": elif typ == "POC":
cursor.execute("INSERT INTO "+globals.config.get("MySQL","tablePOC")+" (time,ric,funktion,funktionChar,msg,bitrate,description) VALUES (NOW(),%s,%s,%s,%s,%s,%s)",(data["ric"],data["function"],data["functionChar"],data["msg"],data["bitrate"],data["description"])) cursor.execute("INSERT INTO "+globals.config.get("MySQL","tablePOC")+" (time,ric,funktion,funktionChar,msg,bitrate,description) VALUES (NOW(),%s,%s,%s,%s,%s,%s)",(data["ric"],data["function"],data["functionChar"],data["msg"],data["bitrate"],data["description"]))
else: else:
logging.warning("Invalid Typ: %s", typ) logging.warning("Invalid Typ: %s", typ)
except: except:
logging.error("cannot Insert %s", typ) logging.error("cannot Insert %s", typ)
logging.debug("cannot Insert %s", typ, exc_info=True) logging.debug("cannot Insert %s", typ, exc_info=True)
return return
finally: finally:
logging.debug("close MySQL") logging.debug("close MySQL")
try: try:
cursor.close() cursor.close()
connection.close() #Close connection in every case connection.close() #Close connection in every case
except: except:
pass pass
except: except:
logging.error("unknown error") logging.error("unknown error")
logging.debug("unknown error", exc_info=True) logging.debug("unknown error", exc_info=True)

View file

@ -31,7 +31,7 @@ def onLoad():
this onLoad() routine is called one time for initialize the plugin this onLoad() routine is called one time for initialize the plugin
@requires: nothing @requires: nothing
@return: nothing @return: nothing
""" """
# nothing to do for this plugin # nothing to do for this plugin
@ -51,11 +51,11 @@ def doSendmail(server, subject, mailtext):
@param subject: Subject for the eMail @param subject: Subject for the eMail
@type mailtext: string @type mailtext: string
@param mailtext: Mailtext for the eMail @param mailtext: Mailtext for the eMail
@return: nothing @return: nothing
@exception: Exception if smtp.sendmail failed @exception: Exception if smtp.sendmail failed
""" """
try: try:
msg = MIMEText(mailtext) msg = MIMEText(mailtext)
msg['From'] = globals.config.get("eMail", "from") msg['From'] = globals.config.get("eMail", "from")
msg['To'] = globals.config.get("eMail", "to") msg['To'] = globals.config.get("eMail", "to")
@ -79,7 +79,7 @@ def run(typ,freq,data):
""" """
This function is the implementation of the eMail-Plugin. This function is the implementation of the eMail-Plugin.
It will send the data via eMail (SMTP) It will send the data via eMail (SMTP)
The configuration for the eMail-Connection is set in the config.ini. The configuration for the eMail-Connection is set in the config.ini.
If an user is set, the HTTP-Request is authenticatet. If an user is set, the HTTP-Request is authenticatet.
@ -91,7 +91,7 @@ def run(typ,freq,data):
@keyword freq: frequency of the SDR Stick @keyword freq: frequency of the SDR Stick
@requires: eMail-Configuration has to be set in the config.ini @requires: eMail-Configuration has to be set in the config.ini
@return: nothing @return: nothing
""" """
try: try:
@ -102,7 +102,7 @@ def run(typ,freq,data):
try: try:
for key,val in globals.config.items("eMail"): for key,val in globals.config.items("eMail"):
logging.debug(" - %s = %s", key, val) logging.debug(" - %s = %s", key, val)
except: except:
logging.error("cannot read config file") logging.error("cannot read config file")
logging.debug("cannot read config file", exc_info=True) logging.debug("cannot read config file", exc_info=True)
@ -115,15 +115,15 @@ def run(typ,freq,data):
server = smtplib.SMTP(globals.config.get("eMail", "smtp_server"), globals.config.get("eMail", "smtp_port")) server = smtplib.SMTP(globals.config.get("eMail", "smtp_server"), globals.config.get("eMail", "smtp_port"))
# debug-level to shell (0=no debug|1) # debug-level to shell (0=no debug|1)
server.set_debuglevel(0) server.set_debuglevel(0)
# if tls is enabled, starttls # if tls is enabled, starttls
if globals.config.get("eMail", "tls"): if globals.config.get("eMail", "tls"):
server.starttls() server.starttls()
# if user is given, login # if user is given, login
if globals.config.get("eMail", "user"): if globals.config.get("eMail", "user"):
server.login(globals.config.get("eMail", "user"), globals.config.get("eMail", "password")) server.login(globals.config.get("eMail", "user"), globals.config.get("eMail", "password"))
except: except:
logging.error("cannot connect to eMail") logging.error("cannot connect to eMail")
logging.debug("cannot connect to eMail", exc_info=True) logging.debug("cannot connect to eMail", exc_info=True)
@ -199,18 +199,18 @@ def run(typ,freq,data):
logging.error("%s to eMail failed", typ) logging.error("%s to eMail failed", typ)
logging.debug("%s to eMail failed", typ, exc_info=True) logging.debug("%s to eMail failed", typ, exc_info=True)
return return
else: else:
logging.warning("Invalid Typ: %s", typ) logging.warning("Invalid Typ: %s", typ)
finally: finally:
logging.debug("close eMail-Connection") logging.debug("close eMail-Connection")
try: try:
server.quit() server.quit()
except: except:
pass pass
except: except:
# something very mysterious # something very mysterious
logging.error("unknown error") logging.error("unknown error")
logging.debug("unknown error", exc_info=True) logging.debug("unknown error", exc_info=True)

View file

@ -25,12 +25,12 @@ def onLoad():
this onLoad() routine is called one time for initialize the plugin this onLoad() routine is called one time for initialize the plugin
@requires: nothing @requires: nothing
@return: nothing @return: nothing
""" """
# nothing to do for this plugin # nothing to do for this plugin
return return
## ##
# #
@ -41,7 +41,7 @@ def run(typ,freq,data):
""" """
This function is the implementation of the firEmergency-Plugin. This function is the implementation of the firEmergency-Plugin.
It will send the data to an firEmergency-Instance. It will send the data to an firEmergency-Instance.
The configuration for the firEmergency-Connection is set in the config.ini. The configuration for the firEmergency-Connection is set in the config.ini.
@type typ: string (ZVEI|POC) @type typ: string (ZVEI|POC)
@ -52,7 +52,7 @@ def run(typ,freq,data):
@keyword freq: frequency is not used in this plugin @keyword freq: frequency is not used in this plugin
@requires: firEmergency-Configuration has to be set in the config.ini @requires: firEmergency-Configuration has to be set in the config.ini
@return: nothing @return: nothing
""" """
try: try:
@ -79,14 +79,14 @@ def run(typ,freq,data):
logging.debug("cannot connect to firEmergency", exc_info=True) logging.debug("cannot connect to firEmergency", exc_info=True)
# Without connection, plugin couldn't work # Without connection, plugin couldn't work
return return
else: else:
# #
# Format given data-structure to xml-string for firEmergency # Format given data-structure to xml-string for firEmergency
# #
if typ == "FMS": if typ == "FMS":
logging.debug("FMS not supported by firEmgency") logging.debug("FMS not supported by firEmgency")
elif typ == "ZVEI": elif typ == "ZVEI":
logging.debug("ZVEI to firEmergency") logging.debug("ZVEI to firEmergency")
try: try:
@ -97,7 +97,7 @@ def run(typ,freq,data):
logging.debug("%s to firEmergency failed", typ, exc_info=True) logging.debug("%s to firEmergency failed", typ, exc_info=True)
# Without connection, plugin couldn't work # Without connection, plugin couldn't work
return return
elif typ == "POC": elif typ == "POC":
logging.debug("POC to firEmergency") logging.debug("POC to firEmergency")
try: try:
@ -110,15 +110,15 @@ def run(typ,freq,data):
return return
else: else:
logging.warning("Invalid Typ: %s", typ) logging.warning("Invalid Typ: %s", typ)
finally: finally:
logging.debug("close firEmergency-Connection") logging.debug("close firEmergency-Connection")
try: try:
firSocket.close() firSocket.close()
except: except:
pass pass
except: except:
logging.error("unknown error") logging.error("unknown error")
logging.debug("unknown error", exc_info=True) logging.debug("unknown error", exc_info=True)

View file

@ -28,12 +28,12 @@ def onLoad():
this onLoad() routine is called one time for initialize the plugin this onLoad() routine is called one time for initialize the plugin
@requires: nothing @requires: nothing
@return: nothing @return: nothing
""" """
# nothing to do for this plugin # nothing to do for this plugin
return return
## ##
# #
@ -53,7 +53,7 @@ def run(typ,freq,data):
@keyword freq: frequency of the SDR Stick @keyword freq: frequency of the SDR Stick
@requires: httpRequest-Configuration has to be set in the config.ini @requires: httpRequest-Configuration has to be set in the config.ini
@return: nothing @return: nothing
""" """
try: try:
@ -68,13 +68,13 @@ def run(typ,freq,data):
logging.error("cannot read config file") logging.error("cannot read config file")
logging.debug("cannot read config file", exc_info=True) logging.debug("cannot read config file", exc_info=True)
else: # Without config, plugin couldn't work else: # Without config, plugin couldn't work
try: try:
# #
# Create URL # Create URL
# #
logging.debug("send %s HTTP request", typ) logging.debug("send %s HTTP request", typ)
if typ == "FMS": if typ == "FMS":
url = globals.config.get("httpRequest", "fms_url") #Get URL url = globals.config.get("httpRequest", "fms_url") #Get URL
url = url.replace("%FMS%", data["fms"]).replace("%STATUS%", data["status"]) #replace Wildcards url = url.replace("%FMS%", data["fms"]).replace("%STATUS%", data["status"]) #replace Wildcards
@ -89,29 +89,29 @@ def run(typ,freq,data):
url = url.replace("%FUNC%", data["function"]).replace("%FUNCCHAR%", data["functionChar"]) #replace Wildcards url = url.replace("%FUNC%", data["function"]).replace("%FUNCCHAR%", data["functionChar"]) #replace Wildcards
url = url.replace("%MSG%", data["msg"]).replace("%BITRATE%", str(data["bitrate"])) #replace Wildcards url = url.replace("%MSG%", data["msg"]).replace("%BITRATE%", str(data["bitrate"])) #replace Wildcards
else: else:
logging.warning("Invalid Typ: %s", typ) logging.warning("Invalid Typ: %s", typ)
return return
#same in all types #same in all types
url = url.replace("%DESCR%", data["description"]) # replace Wildcards url = url.replace("%DESCR%", data["description"]) # replace Wildcards
url = url.replace("%TIME%", helper.curtime("%H:%M:%S")) # replace Wildcards url = url.replace("%TIME%", helper.curtime("%H:%M:%S")) # replace Wildcards
url = url.replace("%DATE%", helper.curtime("%d.%m.%Y")) # replace Wildcards url = url.replace("%DATE%", helper.curtime("%d.%m.%Y")) # replace Wildcards
# #
# HTTP-Request # HTTP-Request
# #
url = urlparse(url) #split URL into path and querry url = urlparse(url) #split URL into path and querry
httprequest = httplib.HTTPConnection(url[2]) #connect to URL Path httprequest = httplib.HTTPConnection(url[2]) #connect to URL Path
httprequest.request("GET", url[5]) #send URL Querry per GET httprequest.request("GET", url[5]) #send URL Querry per GET
except: except:
logging.error("cannot send HTTP request") logging.error("cannot send HTTP request")
logging.debug("cannot send HTTP request", exc_info=True) logging.debug("cannot send HTTP request", exc_info=True)
return return
else: else:
try: try:
# #
# check HTTP-Response # check HTTP-Response
# #
httpresponse = httprequest.getresponse() httpresponse = httprequest.getresponse()
@ -123,14 +123,14 @@ def run(typ,freq,data):
logging.error("cannot get HTTP response") logging.error("cannot get HTTP response")
logging.debug("cannot get HTTP response", exc_info=True) logging.debug("cannot get HTTP response", exc_info=True)
return return
finally: finally:
logging.debug("close HTTP-Connection") logging.debug("close HTTP-Connection")
try: try:
httprequest.close() httprequest.close()
except: except:
pass pass
except: except:
logging.error("unknown error") logging.error("unknown error")
logging.debug("unknown error", exc_info=True) logging.debug("unknown error", exc_info=True)

View file

@ -52,16 +52,16 @@ def onLoad():
this onLoad() routine is called one time for initialize the plugin this onLoad() routine is called one time for initialize the plugin
@requires: nothing @requires: nothing
@return: nothing @return: nothing
@exception: Exception if init has an fatal error so that the plugin couldn't work @exception: Exception if init has an fatal error so that the plugin couldn't work
""" """
def run(typ,freq,data): def run(typ,freq,data):
""" """
This function is the implementation of the Plugin. This function is the implementation of the Plugin.
If necessary the configuration hast to be set in the config.ini. If necessary the configuration hast to be set in the config.ini.
@type typ: string (FMS|ZVEI|POC) @type typ: string (FMS|ZVEI|POC)
@ -72,7 +72,7 @@ def run(typ,freq,data):
@keyword freq: frequency of the SDR Stick @keyword freq: frequency of the SDR Stick
@requires: If necessary the configuration hast to be set in the config.ini. @requires: If necessary the configuration hast to be set in the config.ini.
@return: nothing @return: nothing
@exception: nothing, make sure this function will never thrown an exception @exception: nothing, make sure this function will never thrown an exception
""" """
@ -83,4 +83,4 @@ Global Functions for plugins:
from includes import helper #Global helper functions from includes import helper #Global helper functions
helper.curtime("FORMAT") helper.curtime("FORMAT")

View file

@ -27,12 +27,12 @@ def onLoad():
this onLoad() routine is called one time for initialize the plugin this onLoad() routine is called one time for initialize the plugin
@requires: nothing @requires: nothing
@return: nothing @return: nothing
""" """
# nothing to do for this plugin # nothing to do for this plugin
return return
## ##
# #
@ -43,7 +43,7 @@ def run(typ,freq,data):
""" """
This function is the implementation of the jsonSocket-Plugin. This function is the implementation of the jsonSocket-Plugin.
It will send the data via UDP/TCP It will send the data via UDP/TCP
The configuration for the Connection is set in the config.ini. The configuration for the Connection is set in the config.ini.
@type typ: string (FMS|ZVEI|POC) @type typ: string (FMS|ZVEI|POC)
@ -54,7 +54,7 @@ def run(typ,freq,data):
@keyword freq: frequency of the SDR Stick @keyword freq: frequency of the SDR Stick
@requires: jsonSocket-Configuration has to be set in the config.ini @requires: jsonSocket-Configuration has to be set in the config.ini
@return: nothing @return: nothing
""" """
try: try:
@ -65,7 +65,7 @@ def run(typ,freq,data):
try: try:
for key,val in globals.config.items("jsonSocket"): for key,val in globals.config.items("jsonSocket"):
logging.debug(" - %s = %s", key, val) logging.debug(" - %s = %s", key, val)
except: except:
logging.error("cannot read config file") logging.error("cannot read config file")
logging.debug("cannot read config file", exc_info=True) logging.debug("cannot read config file", exc_info=True)
@ -82,7 +82,7 @@ def run(typ,freq,data):
sock.connect((globals.config.get("jsonSocket", "server"), globals.config.getint("jsonSocket", "port"))) sock.connect((globals.config.get("jsonSocket", "server"), globals.config.getint("jsonSocket", "port")))
else: else:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
except: except:
logging.error("cannot initialize %s-socket", globals.config.get("jsonSocket", "protocol")) logging.error("cannot initialize %s-socket", globals.config.get("jsonSocket", "protocol"))
logging.debug("cannot initialize %s-socket", globals.config.get("jsonSocket", "protocol"), exc_info=True) logging.debug("cannot initialize %s-socket", globals.config.get("jsonSocket", "protocol"), exc_info=True)
@ -105,16 +105,16 @@ def run(typ,freq,data):
return return
else: else:
logging.warning("Invalid Typ: %s", typ) logging.warning("Invalid Typ: %s", typ)
finally: finally:
logging.debug("close %s-Connection", globals.config.get("jsonSocket", "protocol")) logging.debug("close %s-Connection", globals.config.get("jsonSocket", "protocol"))
try: try:
sock.close() sock.close()
except: except:
pass pass
except: except:
# something very mysterious # something very mysterious
logging.error("unknown error") logging.error("unknown error")
logging.debug("unknown error", exc_info=True) logging.debug("unknown error", exc_info=True)

View file

@ -36,10 +36,10 @@ def onLoad():
this onLoad() routine is called one time for initialize the plugin this onLoad() routine is called one time for initialize the plugin
@requires: nothing @requires: nothing
@return: nothing @return: nothing
@exception: Exception if init has an fatal error so that the plugin couldn't work @exception: Exception if init has an fatal error so that the plugin couldn't work
""" """
try: try:
########## User onLoad CODE ########## ########## User onLoad CODE ##########
@ -58,7 +58,7 @@ def onLoad():
def run(typ,freq,data): def run(typ,freq,data):
""" """
This function is the implementation of the Plugin. This function is the implementation of the Plugin.
If necessary the configuration hast to be set in the config.ini. If necessary the configuration hast to be set in the config.ini.
@type typ: string (FMS|ZVEI|POC) @type typ: string (FMS|ZVEI|POC)
@ -69,7 +69,7 @@ def run(typ,freq,data):
@keyword freq: frequency of the SDR Stick @keyword freq: frequency of the SDR Stick
@requires: If necessary the configuration hast to be set in the config.ini. @requires: If necessary the configuration hast to be set in the config.ini.
@return: nothing @return: nothing
@exception: nothing, make sure this function will never thrown an exception @exception: nothing, make sure this function will never thrown an exception
""" """
@ -85,8 +85,8 @@ def run(typ,freq,data):
logging.error("cannot read config file") logging.error("cannot read config file")
logging.debug("cannot read config file", exc_info=True) logging.debug("cannot read config file", exc_info=True)
else: # Without config, plugin couldn't work else: # Without config, plugin couldn't work
########## User Plugin CODE ########## ########## User Plugin CODE ##########
if typ == "FMS": if typ == "FMS":
logging.warning("%s not supported", typ) logging.warning("%s not supported", typ)
elif typ == "ZVEI": elif typ == "ZVEI":
@ -94,9 +94,9 @@ def run(typ,freq,data):
elif typ == "POC": elif typ == "POC":
logging.warning("%s not supported", typ) logging.warning("%s not supported", typ)
else: else:
logging.warning("Invalid Typ: %s", typ) logging.warning("Invalid Typ: %s", typ)
########## User Plugin CODE ########## ########## User Plugin CODE ##########
except: except:
logging.error("unknown error") logging.error("unknown error")
logging.debug("unknown error", exc_info=True) logging.debug("unknown error", exc_info=True)

View file

@ -16,7 +16,7 @@ Implemented functions:
- siren will run with the pack - siren will run with the pack
- press Pibrella button to stop alarm and reset the LEDs - press Pibrella button to stop alarm and reset the LEDs
@author: Jens Herrmann @author: Jens Herrmann
BOSWatch: https://github.com/Schrolli91/BOSWatch BOSWatch: https://github.com/Schrolli91/BOSWatch
Pibrella: https://github.com/pimoroni/pibrella Pibrella: https://github.com/pimoroni/pibrella
@ -39,7 +39,7 @@ import json # for data
# #
# Eventhandler for button # Eventhandler for button
# will stop the alarm and reset the LEDs # will stop the alarm and reset the LEDs
# #
def button_pressed(pin): def button_pressed(pin):
global siren_stopped global siren_stopped
import pibrella import pibrella
@ -75,15 +75,15 @@ pibrella.async_start('siren',siren)
# #
# Main Program # Main Program
# #
try: try:
# Logging # Logging
myLogger = logging.getLogger() myLogger = logging.getLogger()
myLogger.setLevel(logging.DEBUG) myLogger.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s [%(levelname)-8s] %(message)s', '%d.%m.%Y %H:%M:%S') formatter = logging.Formatter('%(asctime)s [%(levelname)-8s] %(message)s', '%d.%m.%Y %H:%M:%S')
ch = logging.StreamHandler() ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG) ch.setLevel(logging.DEBUG)
ch.setFormatter(formatter) ch.setFormatter(formatter)
myLogger.addHandler(ch) myLogger.addHandler(ch)
# Start TCP socket: # Start TCP socket:
logging.debug("Start jsonSocketServer") logging.debug("Start jsonSocketServer")
@ -91,7 +91,7 @@ try:
sock.bind((IP,PORT)) sock.bind((IP,PORT))
sock.listen(2) sock.listen(2)
logging.info("jsonSocketServer runs") logging.info("jsonSocketServer runs")
pibrella.light.green.on() pibrella.light.green.on()
# our Alarm-RICs: # our Alarm-RICs:
ric_alarm = [12345677, 12345676, 12345675] ric_alarm = [12345677, 12345676, 12345675]
@ -116,7 +116,7 @@ try:
if parsed_json['ric'] == "1234567": if parsed_json['ric'] == "1234567":
logging.debug("POCSAG is alive") logging.debug("POCSAG is alive")
pibrella.light.green.blink(1, 1) pibrella.light.green.blink(1, 1)
elif int(parsed_json['ric']) in ric_alarm: elif int(parsed_json['ric']) in ric_alarm:
logging.debug("We have do to something") logging.debug("We have do to something")
if parsed_json['functionChar'] == "a": if parsed_json['functionChar'] == "a":
@ -127,22 +127,22 @@ try:
pibrella.light.red.blink(1, 1) pibrella.light.red.blink(1, 1)
# change variable to False to start the siren # change variable to False to start the siren
siren_stopped = False siren_stopped = False
except KeyboardInterrupt: except KeyboardInterrupt:
logging.warning("Keyboard Interrupt") logging.warning("Keyboard Interrupt")
except: except:
logging.exception("unknown error") logging.exception("unknown error")
finally: finally:
try: try:
logging.debug("socketServer shuting down") logging.debug("socketServer shuting down")
sock.close() sock.close()
logging.debug("socket closed") logging.debug("socket closed")
logging.debug("exiting socketServer") logging.debug("exiting socketServer")
except: except:
logging.warning("failed in clean-up routine") logging.warning("failed in clean-up routine")
finally: finally:
logging.debug("close Logging") logging.debug("close Logging")
logging.info("socketServer exit()") logging.info("socketServer exit()")
logging.shutdown() logging.shutdown()
ch.close() ch.close()
exit(0) exit(0)

View file

@ -2,8 +2,8 @@
##### Changing the init script ##### Changing the init script
Lines 14 and 15 define where to find the Python script. Lines 14 and 15 define where to find the Python script.
In this case the script expects that there is a folder `/usr/local/bin/BOSWatch` and that the script is inside there. In this case the script expects that there is a folder `/usr/local/bin/BOSWatch` and that the script is inside there.
Line 23 sets what user to run the script as. Using a root-user is necessary for BOSWatch. Line 23 sets what user to run the script as. Using a root-user is necessary for BOSWatch.
@ -14,15 +14,15 @@ We recommend to use "-u" and "-q" when you want to run BOSWatch as a daemon.
##### Using the init script ##### Using the init script
To actually use this script, put BOSWatch where you want (recommend `/usr/local/bin/BOSWatch`) To actually use this script, put BOSWatch where you want (recommend `/usr/local/bin/BOSWatch`)
and make sure it is executable (e.g. `sudo chmod 755 boswatch.py`). and make sure it is executable (e.g. `sudo chmod 755 boswatch.py`).
Edit the init script accordingly. Copy it into /etc/init.d using e.g. `sudo cp boswatch.sh /etc/init.d`. Edit the init script accordingly. Copy it into /etc/init.d using e.g. `sudo cp boswatch.sh /etc/init.d`.
Make sure the script is executable (chmod again) and make sure that it has UNIX line-endings. Make sure the script is executable (chmod again) and make sure that it has UNIX line-endings.
At this point you should be able to start BOSWatchcd ~/srt using the command `sudo /etc/init.d/boswatch.sh start`, At this point you should be able to start BOSWatchcd ~/srt using the command `sudo /etc/init.d/boswatch.sh start`,
check its status with the `sudo /etc/init.d/boswatch.sh status` argument and stop it with `sudo /etc/init.d/boswatch.sh stop`. check its status with the `sudo /etc/init.d/boswatch.sh status` argument and stop it with `sudo /etc/init.d/boswatch.sh stop`.
To make the Raspberry Pi use your init script at the right time, one more step is required: To make the Raspberry Pi use your init script at the right time, one more step is required:
Running the command `sudo update-rc.d boswatch.sh defaults`. Running the command `sudo update-rc.d boswatch.sh defaults`.
This command adds in symbolic links to the /etc/rc.x directories so that the init script is run at the default times. This command adds in symbolic links to the /etc/rc.x directories so that the init script is run at the default times.
You can see these links if you do `ls -l /etc/rc?.d/*boswatch.sh` You can see these links if you do `ls -l /etc/rc?.d/*boswatch.sh`

View file

@ -4,4 +4,4 @@ fprintf(stderr, "Signal caught, exiting!\n");
fprintf(stderr, "Failed to open rtlsdr device #%d.\n", dongle.dev_index); fprintf(stderr, "Failed to open rtlsdr device #%d.\n", dongle.dev_index);
fprintf(stderr, "Failed to open %s\n", output.filename); fprintf(stderr, "Failed to open %s\n", output.filename);
fprintf(stderr, "\nUser cancel, exiting...\n"); fprintf(stderr, "\nUser cancel, exiting...\n");
fprintf(stderr, "\nLibrary error %d, exiting...\n", r); fprintf(stderr, "\nLibrary error %d, exiting...\n", r);

View file

@ -37,4 +37,4 @@ ZVEI2: 1F2F3
ZVEI2: 135 ZVEI2: 135
#in case of a double-tone for siren n-'D's are sended #in case of a double-tone for siren n-'D's are sended
ZVEI2: DDD ZVEI2: DDD
ZVEI2: DDDDD ZVEI2: DDDDD

View file

@ -9,4 +9,4 @@ $tableFMS = "bos_fms";
$tableZVEI = "bos_zvei"; $tableZVEI = "bos_zvei";
$tablePOC = "bos_pocsag"; $tablePOC = "bos_pocsag";
?> ?>

View file

@ -17,12 +17,12 @@ $db = new Database($dbhost, $dbuser, $dbpassword, $database, 1); //Show Error =
<div style="text-align: center; width: 1250px; margin: 0px auto;"> <div style="text-align: center; width: 1250px; margin: 0px auto;">
<img src="gfx/logo.png" alt="BOSWatch"><br> <img src="gfx/logo.png" alt="BOSWatch"><br>
<a href="index.php?overview">[Übersicht]</a> - <a href="index.php?parser">[Parser]</a> <a href="index.php?overview">[<EFBFBD>bersicht]</a> - <a href="index.php?parser">[Parser]</a>
<br><br> <br><br>
<?php <?php
if(isset($_GET['overview'])) if(isset($_GET['overview']))
{ {
include("tpl/content.overview.php"); include("tpl/content.overview.php");
@ -38,9 +38,9 @@ $db = new Database($dbhost, $dbuser, $dbpassword, $database, 1); //Show Error =
include("tpl/content.overview.php"); include("tpl/content.overview.php");
include("tpl/template.overview.php"); include("tpl/template.overview.php");
} }
?> ?>
</div> </div>
</body> </body>
</html> </html>

View file

@ -10,9 +10,9 @@ Simple Database Class (C) by Bastian Schroll
/** /**
* Database::__construct() * Database::__construct()
* *
* Stellt eine Verbung mit der MySQL Datenbank fest * Stellt eine Verbung mit der MySQL Datenbank fest
* *
* @param mixed $host Hostname des Datenbank Server * @param mixed $host Hostname des Datenbank Server
* @param mixed $user Username des Datenbank Nutzers * @param mixed $user Username des Datenbank Nutzers
* @param mixed $password Passwort des Datenbank Nutzers * @param mixed $password Passwort des Datenbank Nutzers
@ -40,10 +40,10 @@ Simple Database Class (C) by Bastian Schroll
/** /**
* Database::query() * Database::query()
* *
* Führt einen MySQL Query aus * F<EFBFBD>hrt einen MySQL Query aus
* *
* @param mixed $query Auszuführender Query * @param mixed $query Auszuf<EFBFBD>hrender Query
* @return Result-Handler/FALSE * @return Result-Handler/FALSE
*/ */
function query($query) function query($query)
@ -59,11 +59,11 @@ Simple Database Class (C) by Bastian Schroll
/** /**
* Database::fetchAssoc() * Database::fetchAssoc()
* *
* Liefert alle gefundnen Datensätze als Assoc * Liefert alle gefundnen Datens<EFBFBD>tze als Assoc
* *
* @param mixed $result Externer Result-Handler * @param mixed $result Externer Result-Handler
* @return gefundene Datensätze als Assoc * @return gefundene Datens<EFBFBD>tze als Assoc
*/ */
function fetchAssoc($result = null) function fetchAssoc($result = null)
{ {
@ -78,11 +78,11 @@ Simple Database Class (C) by Bastian Schroll
/** /**
* Database::count() * Database::count()
* *
* Zählt alle gefundenen Datensätze * Z<EFBFBD>hlt alle gefundenen Datens<EFBFBD>tze
* *
* @param mixed $result Externer Result-Handler * @param mixed $result Externer Result-Handler
* @return Anzahl gefundener Datensätze * @return Anzahl gefundener Datens<EFBFBD>tze
*/ */
function count($result = null) function count($result = null)
{ {
@ -97,9 +97,9 @@ Simple Database Class (C) by Bastian Schroll
/** /**
* Database::closeConnection() * Database::closeConnection()
* *
* Schließt die bestehende MySQL Verbindung * Schlie<EFBFBD>t die bestehende MySQL Verbindung
* *
* @return TRUE/FALSE * @return TRUE/FALSE
*/ */
function closeConnection() function closeConnection()
@ -114,9 +114,9 @@ Simple Database Class (C) by Bastian Schroll
/** /**
* Database::error() * Database::error()
* *
* Gibt eine Interne Fehlermeldung aus * Gibt eine Interne Fehlermeldung aus
* *
* @param mixed $error_msg Text der Fehlermeldung * @param mixed $error_msg Text der Fehlermeldung
* @param mixed $sql_err MySQL Fehlermeldung per mysql_error() * @param mixed $sql_err MySQL Fehlermeldung per mysql_error()
* @return NULL * @return NULL
@ -131,4 +131,4 @@ Simple Database Class (C) by Bastian Schroll
} }
} }
} ?> } ?>

View file

@ -7,7 +7,7 @@
$Rows[] = $daten; $Rows[] = $daten;
} }
$tpl['fms'] = $Rows; $tpl['fms'] = $Rows;
//read ZVEI //read ZVEI
$db->query("SELECT id, time, zvei FROM ".$tableZVEI." ORDER BY id DESC LIMIT 50"); $db->query("SELECT id, time, zvei FROM ".$tableZVEI." ORDER BY id DESC LIMIT 50");
$Rows = array(); $Rows = array();

View file

@ -1,3 +1,3 @@
<?php <?php
?> ?>

View file

@ -1,5 +1,5 @@
Last alarms for FMS and ZVEI (max. 50)<br><br> Last alarms for FMS and ZVEI (max. 50)<br><br>
<div style="float: left; width: 800px;"> <div style="float: left; width: 800px;">
<b>Last FMS alarms</b> <b>Last FMS alarms</b>
<table border="1" style="width: 800px;"> <table border="1" style="width: 800px;">
@ -11,13 +11,13 @@ Last alarms for FMS and ZVEI (max. 50)<br><br>
<td>Richt.</td> <td>Richt.</td>
<td>TKI</td> <td>TKI</td>
</tr> </tr>
<?php <?php
foreach ($tpl['fms'] as $fms) foreach ($tpl['fms'] as $fms)
{ {
$time = strtotime($fms['time']); $time = strtotime($fms['time']);
$time = date("d.m.Y H:i:s", $time); $time = date("d.m.Y H:i:s", $time);
echo "<tr>"; echo "<tr>";
echo "<td>". $fms['id'] . "</td>"; echo "<td>". $fms['id'] . "</td>";
echo "<td>". $time . "</td>"; echo "<td>". $time . "</td>";
@ -39,13 +39,13 @@ Last alarms for FMS and ZVEI (max. 50)<br><br>
<td>Funktion</td> <td>Funktion</td>
<td>Text</td> <td>Text</td>
</tr> </tr>
<?php <?php
foreach ($tpl['poc'] as $poc) foreach ($tpl['poc'] as $poc)
{ {
$time = strtotime($poc['time']); $time = strtotime($poc['time']);
$time = date("d.m.Y H:i:s", $time); $time = date("d.m.Y H:i:s", $time);
echo "<tr>"; echo "<tr>";
echo "<td>". $poc['id'] . "</td>"; echo "<td>". $poc['id'] . "</td>";
echo "<td>". $time . "</td>"; echo "<td>". $time . "</td>";
@ -57,7 +57,7 @@ Last alarms for FMS and ZVEI (max. 50)<br><br>
?> ?>
</table> </table>
</div> </div>
<div style="float: right; width: 400px;"> <div style="float: right; width: 400px;">
<b>Last ZVEI alarms</b> <b>Last ZVEI alarms</b>
<table border="1" style="width: 400px;"> <table border="1" style="width: 400px;">
@ -66,13 +66,13 @@ Last alarms for FMS and ZVEI (max. 50)<br><br>
<td>Datum - Zeit</td> <td>Datum - Zeit</td>
<td>Schleife</td> <td>Schleife</td>
</tr> </tr>
<?php <?php
foreach ($tpl['zvei'] as $zvei) foreach ($tpl['zvei'] as $zvei)
{ {
$time = strtotime($zvei['time']); $time = strtotime($zvei['time']);
$time = date("d.m.Y H:i:s", $time); $time = date("d.m.Y H:i:s", $time);
echo "<tr>"; echo "<tr>";
echo "<td>". $zvei['id'] . "</td>"; echo "<td>". $zvei['id'] . "</td>";
echo "<td>". $time . "</td>"; echo "<td>". $time . "</td>";