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
library. If this is what you want to do, use the GNU Lesser General
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
@author: Bastian Schroll
@author: Jens Herrmann
@author: Jens Herrmann
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
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 signalHandler # TERM-Handler for use script as a daemon
from includes import checkSubprocesses # check startup of the subprocesses
#
# ArgParser
# Have to be before main program
#
try:
try:
# With -h or --help you get the Args help
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",
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",
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("-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("-v", "--verbose", help="Shows more information", 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")
args = parser.parse_args()
args = parser.parse_args()
except SystemExit:
# -h or --help called, exit right now
exit(0)
@ -60,7 +60,7 @@ except:
print "ERROR: cannot parsing the arguments"
exit(1)
#
# Main program
#
@ -106,26 +106,26 @@ try:
fh = MyTimedRotatingFileHandler.MyTimedRotatingFileHandler(globals.log_path+"boswatch.log", "midnight", interval=1, backupCount=999)
# Starts with log level >= Debug
# will be changed with config.ini-param later
fh.setLevel(logging.DEBUG)
fh.setLevel(logging.DEBUG)
fh.setFormatter(formatter)
myLogger.addHandler(fh)
# create a display logger
ch = logging.StreamHandler()
# log level for display: Default: info
if args.verbose:
ch.setLevel(logging.DEBUG)
ch.setLevel(logging.DEBUG)
elif args.quiet:
ch.setLevel(logging.CRITICAL)
else:
ch.setLevel(logging.INFO)
ch.setLevel(logging.INFO)
ch.setFormatter(formatter)
myLogger.addHandler(ch)
myLogger.addHandler(ch)
except:
# we couldn't work without logging -> exit
print "ERROR: cannot create logger"
exit(1)
# initialization of the logging was fine, continue...
try:
#
@ -139,29 +139,29 @@ try:
rtl_log.close()
mon_log.close()
logging.debug("BOSWatch has started")
logging.debug("Logfiles cleared")
logging.debug("Logfiles cleared")
except:
# 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)
pass
#
# For debug display/log args
#
try:
try:
logging.debug("SW Version: %s",globals.getVers("vers"))
logging.debug("Build Date: %s",globals.getVers("date"))
logging.debug("BOSWatch given arguments")
if args.test:
logging.debug(" - Test-Mode!")
logging.debug(" - Frequency: %s", converter.freqToHz(args.freq))
logging.debug(" - Device: %s", args.device)
logging.debug(" - PPM Error: %s", args.error)
logging.debug(" - Squelch: %s", args.squelch)
demodulation = ""
if "FMS" in args.demod:
demodulation += "-a FMSFSK "
@ -174,18 +174,18 @@ try:
logging.debug(" - Demod: POC512")
if "POC1200" in args.demod:
demodulation += "-a POCSAG1200 "
logging.debug(" - Demod: POC1200")
logging.debug(" - Demod: POC1200")
if "POC2400" in args.demod:
demodulation += "-a POCSAG2400 "
logging.debug(" - Demod: POC2400")
logging.debug(" - Use /var/log: %s", args.usevarlog)
logging.debug(" - Verbose Mode: %s", args.verbose)
logging.debug(" - Quiet Mode: %s", args.quiet)
if not args.quiet: #only if not quiet mode
from includes import shellHeader
shellHeader.printHeader(args)
shellHeader.printHeader(args)
if args.test:
logging.warning("!!! We are in Test-Mode !!!")
@ -204,7 +204,7 @@ try:
globals.config = ConfigParser.ConfigParser()
globals.config.read(globals.script_path+"/config/config.ini")
# if given loglevel is debug:
if globals.config.getint("BOSWatch","loglevel") == 10:
if globals.config.getint("BOSWatch","loglevel") == 10:
logging.debug(" - BOSWatch:")
for key,val in globals.config.items("BOSWatch"):
logging.debug(" -- %s = %s", key, val)
@ -225,8 +225,8 @@ try:
# initialization was fine, continue with main program...
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"))
fh.setLevel(globals.config.getint("BOSWatch","loglevel"))
@ -237,11 +237,11 @@ try:
logging.error("cannot set loglevel of fileHandler")
logging.debug("cannot set loglevel of fileHandler", exc_info=True)
pass
#
# Load plugins
#
try:
try:
from includes import pluginLoader
pluginLoader.loadPlugins()
except:
@ -249,11 +249,11 @@ try:
logging.critical("cannot load Plugins")
logging.debug("cannot load Plugins", exc_info=True)
exit(1)
#
# Load filters
#
try:
try:
if globals.config.getboolean("BOSWatch","useRegExFilter"):
from includes import filter
filter.loadFilters()
@ -262,11 +262,11 @@ try:
logging.error("cannot load filters")
logging.debug("cannot load filters", exc_info=True)
pass
#
# Load description lists
#
try:
try:
if globals.config.getboolean("FMS","idDescribed") or globals.config.getboolean("ZVEI","idDescribed") or globals.config.getboolean("POC","idDescribed"):
from includes import descriptionList
descriptionList.loadDescriptionLists()
@ -275,11 +275,11 @@ try:
logging.error("cannot load description lists")
logging.debug("cannot load description lists", exc_info=True)
pass
#
# Start rtl_fm
#
try:
try:
if not args.test:
logging.debug("starting rtl_fm")
command = ""
@ -317,7 +317,7 @@ try:
stdin=rtl_fm.stdout,
stdout=subprocess.PIPE,
stderr=open(globals.log_path+"multimon.log","a"),
shell=False)
shell=False)
# multimon-ng doesn't self-destruct, when an error occurs
# wait a moment to give the subprocess a chance to write the logfile
time.sleep(3)
@ -331,15 +331,15 @@ try:
exit(1)
# multimon-ng started, continue...
logging.debug("start decoding")
logging.debug("start decoding")
#
# Get decoded data from multimon-ng and call BOSWatch-decoder
#
while True:
while True:
if not args.test:
decoded = str(multimon_ng.stdout.readline()) #Get line data from multimon stdout
else:
# Test-strings only for develop
#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 0=FZG->LST 2=IV (mit NA,mit SIGNAL)) CRC correct\n'"
decoded = "POCSAG1200: Address: 1234567 Function: 1 Alpha: Hello World"
time.sleep(1)
time.sleep(1)
from includes import decoder
decoder.decode(converter.freqToHz(args.freq), decoded)
except KeyboardInterrupt:
logging.warning("Keyboard Interrupt")
logging.warning("Keyboard Interrupt")
except SystemExit:
# SystemExitException is thrown if daemon was terminated
logging.warning("SystemExit received")
@ -367,24 +367,24 @@ finally:
try:
logging.debug("BOSWatch shuting down")
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.wait()
logging.debug("multimon-ng terminated")
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.wait()
logging.debug("rtl_fm terminated")
logging.debug("exiting BOSWatch")
logging.debug("rtl_fm terminated")
logging.debug("exiting BOSWatch")
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)
finally:
finally:
# Close Logging
logging.debug("close Logging")
logging.debug("close Logging")
logging.info("BOSWatch exit()")
logging.shutdown()
fh.close()
ch.close()
ch.close()

View file

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

View file

@ -7,4 +7,4 @@ fms,description
#
# !!! 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 !!!
#
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 !!!
#
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.
@author: Jens Herrmann
@ -15,4 +15,4 @@ class MyTimedRotatingFileHandler(logging.handlers.TimedRotatingFileHandler):
"""Extended Version of TimedRotatingFileHandler"""
def setBackupCount(self, 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
@requires: active plugins in pluginList
@return: nothing
@exception: Exception if Alarm processing itself failed
"""
@ -41,7 +41,7 @@ def processAlarm(typ,freq,data):
# if enabled use RegEx-filter
if globals.config.getint("BOSWatch","useRegExFilter"):
from includes import filter
if filter.checkFilters(typ,data,pluginName,freq):
if filter.checkFilters(typ,data,pluginName,freq):
logging.debug("call Plugin: %s", pluginName)
try:
plugin.run(typ,freq,data)
@ -59,4 +59,4 @@ def processAlarm(typ,freq,data):
pass
logging.debug("[END ALARM]")
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
Used in boswatch.py at startup and designated for watching-service
@author: Jens Herrmann
@author: Jens Herrmann
"""
import logging
@ -32,7 +32,7 @@ def checkRTL():
logging.critical("cannot check rtl_fm.log")
logging.debug("cannot check rtl_fm.log", exc_info=True)
raise
def checkMultimon():
"""
check startup of multimon-ng
@ -51,4 +51,4 @@ def checkMultimon():
# we couldn't work without multimon-ng
logging.critical("cannot check multimon.log")
logging.debug("cannot check multimon.log", exc_info=True)
raise
raise

View file

@ -13,10 +13,10 @@ import logging
def freqToHz(freq):
"""
gets a frequency and resolve it in Hz
@type freq: string
@param freq: frequency of the SDR Stick
@return: frequency in Hz
@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
return int(float(freq))
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
@type decoded: string
@param decoded: RAW Information from Multimon-NG
@return: nothing
@exception: Exception if decoder file call failed
"""
try:
# FMS Decoder Section
# FMS Decoder Section
# check FMS: -> check CRC -> validate -> check double alarm -> log
if "FMS:" in decoded:
if "FMS:" in decoded:
logging.debug("recieved FMS")
from includes.decoders import fms
fms.decode(freq, decoded)
# ZVEI Decoder Section
# check ZVEI: -> validate -> check double alarm -> log
# check ZVEI: -> validate -> check double alarm -> log
elif "ZVEI2:" in decoded:
logging.debug("recieved ZVEI")
logging.debug("recieved ZVEI")
from includes.decoders import zvei
zvei.decode(freq, decoded)
# 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:
logging.debug("recieved POCSAG")
logging.debug("recieved POCSAG")
from includes.decoders import poc
poc.decode(freq, decoded)
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
# validate -> check double alarm -> log
# validate -> check double alarm -> log
#
def decode(freq, decoded):
"""
@ -30,7 +30,7 @@ def decode(freq, decoded):
@param decoded: RAW Information from Multimon-NG
@requires: Configuration has to be set in the config.ini
@return: nothing
@exception: Exception if FMS decode failed
"""
@ -42,11 +42,11 @@ def decode(freq, decoded):
fms_direction = decoded[101] # Richtung
fms_directionText = decoded[103:110] # Richtung (Text)
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
# 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
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)
@ -66,6 +66,6 @@ def decode(freq, decoded):
# in every time save old data for double alarm
doubleFilter.newEntry(fms_id)
else:
logging.warning("No valid FMS: %s", fms_id)
logging.warning("No valid FMS: %s", fms_id)
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
@requires: Configuration has to be set in the config.ini
@return: True if the Ric is allowed, other False
@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 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
##
#
#
# POCSAG decoder function
# validate -> check double alarm -> log
#
@ -69,38 +69,38 @@ def decode(freq, decoded):
@param decoded: RAW Information from Multimon-NG
@requires: Configuration has to be set in the config.ini
@return: nothing
@exception: Exception if POCSAG decode failed
"""
bitrate = 0
if "POCSAG512:" in decoded:
bitrate = 512
poc_id = decoded[20:27].replace(" ", "").zfill(7)
poc_sub = decoded[39].replace("3", "4").replace("2", "3").replace("1", "2").replace("0", "1")
elif "POCSAG1200:" in decoded:
bitrate = 1200
poc_id = decoded[21:28].replace(" ", "").zfill(7)
poc_sub = decoded[40].replace("3", "4").replace("2", "3").replace("1", "2").replace("0", "1")
elif "POCSAG2400:" in decoded:
bitrate = 2400
poc_id = decoded[21:28].replace(" ", "").zfill(7)
poc_sub = decoded[40].replace("3", "4").replace("2", "3").replace("1", "2").replace("0", "1")
if bitrate is 0:
logging.warning("POCSAG Bitrate not found")
logging.debug(" - (%s)", decoded)
else:
logging.debug("POCSAG Bitrate: %s", bitrate)
if "Alpha:" in decoded: #check if there is a text message
poc_text = decoded.split('Alpha: ')[1].strip().rstrip('<EOT>').strip()
else:
poc_text = ""
if re.search("[0-9]{7}", poc_id): #if POC is valid
if isAllowed(poc_id):
# check for double alarm
@ -126,4 +126,4 @@ def decode(freq, decoded):
else:
logging.debug("POCSAG%s: %s is not allowed", bitrate, poc_id)
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
@param zvei: ZVEI Information
@return: ZVEI without F
@exception: none
"""
@ -40,7 +40,7 @@ def removeF(zvei):
##
#
# ZVEI decoder function
# validate -> check double alarm -> log
# validate -> check double alarm -> log
#
def decode(freq, decoded):
"""
@ -52,11 +52,11 @@ def decode(freq, decoded):
@param decoded: RAW Information from Multimon-NG
@requires: Configuration has to be set in the config.ini
@return: nothing
@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
if re.search("[0-9]{5}", zvei_id): # if ZVEI is valid
# check for double alarm
@ -78,4 +78,4 @@ def decode(freq, decoded):
# in every time save old data for double alarm
doubleFilter.newEntry(zvei_id)
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
return resultList;
##
#
# call this for loading the description lists
@ -62,7 +62,7 @@ def loadDescriptionLists():
if globals.config.getint("FMS", "idDescribed"):
logging.debug("- load FMS description list")
globals.fmsDescribtionList = loadCSV("fms", "fms")
if globals.config.getint("ZVEI", "idDescribed"):
logging.debug("- load ZVEI description list")
globals.zveiDescribtionList = loadCSV("zvei", "zvei")
@ -70,17 +70,17 @@ def loadDescriptionLists():
if globals.config.getint("POC", "idDescribed"):
logging.debug("- load pocsag description list")
globals.ricDescribtionList = loadCSV("poc", "ric")
except:
logging.error("cannot load description lists")
logging.debug("cannot load description lists", exc_info=True)
pass
##
#
# public function for getting a description
#
#
def getDescription(typ, id):
"""
Get description for id.
@ -98,17 +98,17 @@ def getDescription(typ, id):
elif typ == "POC":
resultStr = globals.ricDescribtionList[id]
else:
logging.warning("Invalid Typ: %s", typ)
logging.warning("Invalid Typ: %s", typ)
except KeyError:
# will be thrown when there is no description for the id
# -> nothing to do...
pass
except:
logging.error("Error during look up description lists")
logging.debug("Error during look up description lists", exc_info=True)
pass
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=""):
"""
check if id was called in the last x sec and n entries
@requires: Configuration has to be set in the config.ini
@return: True if check was OK
@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)):
(xID, xTimestamp, xMsg) = globals.doubleList[i]
# given ID found?
# 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 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 msg is a substring of xMsg we found a double
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)
return False
return True
def newEntry(id, msg = ""):
"""
new entry in double alarm list
@return: nothing
"""
timestamp = int(time.time()) # Get Timestamp
timestamp = int(time.time()) # Get Timestamp
globals.doubleList.append((id, timestamp, msg))
logging.debug("Added %s to doubleList", id)
# now check if list has more than n entries:
if len(globals.doubleList) > globals.config.getint("BOSWatch", "doubleFilter_ignore_entries"):
# 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
@requires: Configuration has to be set in the config.ini
@return: nothing
"""
try:
@ -32,11 +32,11 @@ def loadFilters():
for key,val in globals.config.items("Filters"):
logging.debug(" - %s = %s", key, val)
filter = val.split(";")
# resolve the * for freqToHz()
if not filter[3] == "*":
filter[3] = converter.freqToHz(filter[3])
# 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]})
except:
@ -44,12 +44,12 @@ def loadFilters():
logging.debug("cannot read config file", exc_info=True)
return
def checkFilters(typ,data,plugin,freq):
"""
Check the Typ/Plugin combination with the RegEX filter
If no filter for the combination is found, function returns True.
@type typ: string (FMS|ZVEI|POC)
@param typ: Typ of the dataset
@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
@type freq: string
@param freq: frequency of the SDR Stick
@requires: all filters in the filterList
@return: nothing
"""
try:
logging.debug("search Filter for %s to %s at %s Hz", typ, plugin, freq)
foundFilter = False
# go to all filter in globals.filterList
for i in globals.filterList:
@ -79,16 +79,16 @@ def checkFilters(typ,data,plugin,freq):
return True
else:
logging.debug("Filter not passed: %s", i["name"])
if foundFilter:
logging.debug("no Filter passed")
return False
else:
logging.debug("no Filter found")
return True
except:
logging.error("Error in filter checking")
logging.debug("Error in filter checking", exc_info=True)
# something goes wrong, data will path
return True
return True

View file

@ -33,4 +33,4 @@ def getVers(mode="vers"):
if mode == "vers":
return "2.0-RC"
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
see: https://docs.python.org/2/library/time.html#time.strftime
@type format: string
@param format: Python time Format-String
@return: Formated Time and/or Date
@exception: Exception if Error in format
"""
"""
try:
return time.strftime(format)
return time.strftime(format)
except:
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"])
plugin.onLoad()
# Add it to globals.pluginList
globals.pluginList[i["name"]] = plugin
globals.pluginList[i["name"]] = plugin
except:
# call next plugin, if one has thrown an exception
logging.error("error calling %s.onLoad()", i["name"])
@ -60,13 +60,13 @@ def getPlugins():
# Go to all Folders in the Plugin-Dir
for i in os.listdir(PluginFolder):
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):
continue
# is the plugin enabled in the config-file?
try:
try:
if globals.config.getint("Plugins", i):
info = imp.find_module(i, [location])
plugins.append({"name": i, "info": info})
@ -74,8 +74,8 @@ def getPlugins():
else:
logging.debug("Plugin [DISABLED] %s ", i)
# no entry for plugin found in config-file
except NoOptionError:
logging.warning("Plugin [NO CONF ] %s", i)
except NoOptionError:
logging.warning("Plugin [NO CONF ] %s", i)
pass
except:
logging.error("Error during Plugin search")
@ -91,8 +91,8 @@ def loadPlugin(plugin):
@type plugin: Plugin Data
@param plugin: Contains the information to import a Plugin
@return: nothing
@exception: Exception if Plugin import failed
"""
@ -102,4 +102,4 @@ def loadPlugin(plugin):
except:
logging.error("cannot load Plugin: %s", plugin["name"])
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
@param args: All given arguments from argsparser
@return: nothing
"""
try:
print " ____ ____ ______ __ __ __ "
print " / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ "
print " / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ "
print " / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / "
print " /_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ "
print " German BOS Information Script "
print " by Bastian Schroll, Jens Herrmann "
print ""
print " ____ ____ ______ __ __ __ "
print " / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ "
print " / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ "
print " / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / "
print " /_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ "
print " German BOS Information Script "
print " by Bastian Schroll, Jens Herrmann "
print ""
print "SW Version: "+globals.getVers("vers")
print "Build Date: "+globals.getVers("date")
print ""
@ -41,19 +41,19 @@ def printHeader(args):
if "FMS" in args.demod:
print "- FMS"
if "ZVEI" in args.demod:
print "- ZVEI"
print "- ZVEI"
if "POC512" in args.demod:
print "- POC512"
if "POC1200" in args.demod:
print "- POC1200"
if "POC2400" in args.demod:
print "- POC2400"
print "- POC2400"
print "Squelch: "+str(args.squelch)
if args.verbose:
print "Verbose Mode!"
print "Verbose Mode!"
if args.test:
print "Test Mode!"
print ""
print ""
except:
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
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.
@author: Jens Herrmann
@ -19,7 +19,7 @@ def sigterm_handler(_signo, _stack_frame):
TERM-Handler for use script as a daemon
@type _signo: signalnum
@param _signo: signal number
@param _signo: signal number
@type _stack_frame: frame object
@param _stack_frame: current stack frame
@ -29,4 +29,4 @@ def sigterm_handler(_signo, _stack_frame):
sys.exit(0)
# 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
tput clear
tput civis
echo " ____ ____ ______ __ __ __ "
echo " / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ "
echo " / __ / / / /\__ \| | /| / / __ / __/ ___/ __ \ "
echo " / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / "
echo " /_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ "
echo " German BOS Information Script "
echo " by Bastian Schroll "
echo " ____ ____ ______ __ __ __ "
echo " / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ "
echo " / __ / / / /\__ \| | /| / / __ / __/ ___/ __ \ "
echo " / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / "
echo " /_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ "
echo " German BOS Information Script "
echo " by Bastian Schroll "
echo ""
echo "This may take a several minutes... Don't panic!"
echo ""
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"
mkdir -p ~/boswatch/install
mkdir -p ~/boswatch/install
tput cup 13 15
echo "[ 1/10] [#---------]"
@ -32,7 +32,7 @@ tput cup 13 15
echo "[ 3/10] [###-------]"
tput cup 15 5
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
cd rtl-sdr/
@ -50,7 +50,7 @@ tput cup 13 15
echo "[ 5/10] [#####-----]"
tput cup 15 5
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
cd multimonNG/
@ -68,7 +68,7 @@ tput cup 13 15
echo "[ 7/10] [#######---]"
tput cup 15 5
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
tar xfv mysql-connector.tar >> ~/boswatch/install/setup_log.txt 2>&1
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
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
@requires: nothing
@return: nothing
"""
# nothing to do for this plugin
@ -50,7 +50,7 @@ def bosMonRequest(httprequest, params, headers):
@param params: Contains the parameter for transfer to BosMon.
@type headers: map
@param headers: The headers argument should be a mapping of extra HTTP headers to send with the request.
@return: nothing
@exception: Exception if HTTP-Request failed
"""
@ -63,8 +63,8 @@ def bosMonRequest(httprequest, params, headers):
logging.error("request to BosMon failed")
logging.debug("request to BosMon failed", exc_info=True)
raise
else:
#
else:
#
# check HTTP-Response
#
httpresponse = httprequest.getresponse()
@ -82,7 +82,7 @@ def run(typ,freq,data):
"""
This function is the implementation of the BosMon-Plugin.
It will send the data to an BosMon-Instance via http
The configuration for the BosMon-Connection is set in the config.ini.
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
@requires: BosMon-Configuration has to be set in the config.ini
@return: nothing
"""
try:
@ -140,8 +140,8 @@ def run(typ,freq,data):
logging.debug("Start FMS to BosMon")
try:
# BosMon-Telegramin expected assembly group, direction and tsi in one field
# structure (binary as hex in base10):
# Byte 1: assembly group; Byte 2: Direction; Byte 3+4: tactic short info
# structure (binary as hex in base10):
# Byte 1: assembly group; Byte 2: Direction; Byte 3+4: tactic short info
info = 0
# assembly group:
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"]:
info = info + 4 # + b0100
# "I" is nothing to do + b0000
params = urllib.urlencode({'type':'fms', 'address':data["fms"], 'status':data["status"], 'info':info, 'flags':'0'})
logging.debug(" - Params: %s", params)
# dispatch the BosMon-request
# dispatch the BosMon-request
bosMonRequest(httprequest, params, headers)
except:
logging.error("FMS to BosMon failed")
@ -171,7 +171,7 @@ def run(typ,freq,data):
try:
params = urllib.urlencode({'type':'zvei', 'address':data["zvei"], 'flags':'0'})
logging.debug(" - Params: %s", params)
# dispatch the BosMon-request
# dispatch the BosMon-request
bosMonRequest(httprequest, params, headers)
except:
logging.error("ZVEI to BosMon failed")
@ -184,24 +184,24 @@ def run(typ,freq,data):
# 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"]})
logging.debug(" - Params: %s", params)
# dispatch the BosMon-request
# dispatch the BosMon-request
bosMonRequest(httprequest, params, headers)
except:
logging.error("POC to BosMon failed")
logging.debug("POC to BosMon failed", exc_info=True)
return
else:
logging.warning("Invalid Typ: %s", typ)
logging.warning("Invalid Typ: %s", typ)
finally:
logging.debug("close BosMon-Connection")
try:
try:
httprequest.close()
except:
pass
except:
except:
# something very mysterious
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
@requires: nothing
@return: nothing
"""
# nothing to do for this plugin
return
##
#
@ -45,7 +45,7 @@ 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
@ -58,7 +58,7 @@ def run(typ,freq,data):
@requires: MySQL-Configuration has to be set in the config.ini
@requires: Created Database/Tables, see boswatch.sql
@return: nothing
"""
try:
@ -73,7 +73,7 @@ def run(typ,freq,data):
logging.error("cannot read config file")
logging.debug("cannot read config file", exc_info=True)
else: # Without config, plugin couldn't work
try:
#
# Connect to MySQL
@ -83,38 +83,38 @@ def run(typ,freq,data):
cursor = connection.cursor()
except:
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
try:
#
# Create and execute SQL-statement
#
logging.debug("Insert %s", typ)
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"]))
elif typ == "ZVEI":
cursor.execute("INSERT INTO "+globals.config.get("MySQL","tableZVEI")+" (time,zvei,description) VALUES (NOW(),%s,%s)",(data["zvei"],data["description"]))
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"]))
else:
logging.warning("Invalid Typ: %s", typ)
logging.warning("Invalid Typ: %s", typ)
except:
logging.error("cannot Insert %s", typ)
logging.debug("cannot Insert %s", typ, exc_info=True)
return
finally:
logging.debug("close MySQL")
try:
try:
cursor.close()
connection.close() #Close connection in every case
connection.close() #Close connection in every case
except:
pass
except:
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
@requires: nothing
@return: nothing
"""
# nothing to do for this plugin
@ -51,11 +51,11 @@ def doSendmail(server, subject, mailtext):
@param subject: Subject for the eMail
@type mailtext: string
@param mailtext: Mailtext for the eMail
@return: nothing
@exception: Exception if smtp.sendmail failed
"""
try:
try:
msg = MIMEText(mailtext)
msg['From'] = globals.config.get("eMail", "from")
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.
It will send the data via eMail (SMTP)
The configuration for the eMail-Connection is set in the config.ini.
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
@requires: eMail-Configuration has to be set in the config.ini
@return: nothing
"""
try:
@ -102,7 +102,7 @@ def run(typ,freq,data):
try:
for key,val in globals.config.items("eMail"):
logging.debug(" - %s = %s", key, val)
except:
logging.error("cannot read config file")
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"))
# debug-level to shell (0=no debug|1)
server.set_debuglevel(0)
# if tls is enabled, starttls
if globals.config.get("eMail", "tls"):
server.starttls()
# if user is given, login
if globals.config.get("eMail", "user"):
server.login(globals.config.get("eMail", "user"), globals.config.get("eMail", "password"))
except:
logging.error("cannot connect to eMail")
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.debug("%s to eMail failed", typ, exc_info=True)
return
else:
logging.warning("Invalid Typ: %s", typ)
logging.warning("Invalid Typ: %s", typ)
finally:
logging.debug("close eMail-Connection")
try:
try:
server.quit()
except:
pass
except:
# something very mysterious
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
@requires: nothing
@return: nothing
"""
# nothing to do for this plugin
return
##
#
@ -41,7 +41,7 @@ def run(typ,freq,data):
"""
This function is the implementation of the firEmergency-Plugin.
It will send the data to an firEmergency-Instance.
The configuration for the firEmergency-Connection is set in the config.ini.
@type typ: string (ZVEI|POC)
@ -52,7 +52,7 @@ def run(typ,freq,data):
@keyword freq: frequency is not used in this plugin
@requires: firEmergency-Configuration has to be set in the config.ini
@return: nothing
"""
try:
@ -79,14 +79,14 @@ def run(typ,freq,data):
logging.debug("cannot connect to firEmergency", exc_info=True)
# Without connection, plugin couldn't work
return
else:
else:
#
# Format given data-structure to xml-string for firEmergency
#
if typ == "FMS":
logging.debug("FMS not supported by firEmgency")
elif typ == "ZVEI":
logging.debug("ZVEI to firEmergency")
try:
@ -97,7 +97,7 @@ def run(typ,freq,data):
logging.debug("%s to firEmergency failed", typ, exc_info=True)
# Without connection, plugin couldn't work
return
elif typ == "POC":
logging.debug("POC to firEmergency")
try:
@ -110,15 +110,15 @@ def run(typ,freq,data):
return
else:
logging.warning("Invalid Typ: %s", typ)
logging.warning("Invalid Typ: %s", typ)
finally:
logging.debug("close firEmergency-Connection")
try:
try:
firSocket.close()
except:
pass
except:
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
@requires: nothing
@return: nothing
"""
# nothing to do for this plugin
return
##
#
@ -53,7 +53,7 @@ def run(typ,freq,data):
@keyword freq: frequency of the SDR Stick
@requires: httpRequest-Configuration has to be set in the config.ini
@return: nothing
"""
try:
@ -68,13 +68,13 @@ def run(typ,freq,data):
logging.error("cannot read config file")
logging.debug("cannot read config file", exc_info=True)
else: # Without config, plugin couldn't work
try:
#
# Create URL
#
logging.debug("send %s HTTP request", typ)
if typ == "FMS":
url = globals.config.get("httpRequest", "fms_url") #Get URL
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("%MSG%", data["msg"]).replace("%BITRATE%", str(data["bitrate"])) #replace Wildcards
else:
logging.warning("Invalid Typ: %s", typ)
logging.warning("Invalid Typ: %s", typ)
return
#same in all types
url = url.replace("%DESCR%", data["description"]) # replace Wildcards
url = url.replace("%TIME%", helper.curtime("%H:%M:%S")) # replace Wildcards
url = url.replace("%DATE%", helper.curtime("%d.%m.%Y")) # replace Wildcards
#
# 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.error("cannot send HTTP request")
logging.debug("cannot send HTTP request", exc_info=True)
return
else:
try:
#
#
# check HTTP-Response
#
httpresponse = httprequest.getresponse()
@ -123,14 +123,14 @@ def run(typ,freq,data):
logging.error("cannot get HTTP response")
logging.debug("cannot get HTTP response", exc_info=True)
return
finally:
logging.debug("close HTTP-Connection")
try:
try:
httprequest.close()
except:
pass
except:
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
@requires: nothing
@return: nothing
@exception: Exception if init has an fatal error so that the plugin couldn't work
"""
def run(typ,freq,data):
"""
This function is the implementation of the Plugin.
If necessary the configuration hast to be set in the config.ini.
@type typ: string (FMS|ZVEI|POC)
@ -72,7 +72,7 @@ def run(typ,freq,data):
@keyword freq: frequency of the SDR Stick
@requires: If necessary the configuration hast to be set in the config.ini.
@return: nothing
@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
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
@requires: nothing
@return: nothing
"""
# nothing to do for this plugin
return
##
#
@ -43,7 +43,7 @@ def run(typ,freq,data):
"""
This function is the implementation of the jsonSocket-Plugin.
It will send the data via UDP/TCP
The configuration for the Connection is set in the config.ini.
@type typ: string (FMS|ZVEI|POC)
@ -54,7 +54,7 @@ def run(typ,freq,data):
@keyword freq: frequency of the SDR Stick
@requires: jsonSocket-Configuration has to be set in the config.ini
@return: nothing
"""
try:
@ -65,7 +65,7 @@ def run(typ,freq,data):
try:
for key,val in globals.config.items("jsonSocket"):
logging.debug(" - %s = %s", key, val)
except:
logging.error("cannot read config file")
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")))
else:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
except:
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)
@ -105,16 +105,16 @@ def run(typ,freq,data):
return
else:
logging.warning("Invalid Typ: %s", typ)
logging.warning("Invalid Typ: %s", typ)
finally:
logging.debug("close %s-Connection", globals.config.get("jsonSocket", "protocol"))
try:
try:
sock.close()
except:
pass
except:
# something very mysterious
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
@requires: nothing
@return: nothing
@exception: Exception if init has an fatal error so that the plugin couldn't work
"""
try:
########## User onLoad CODE ##########
@ -58,7 +58,7 @@ def onLoad():
def run(typ,freq,data):
"""
This function is the implementation of the Plugin.
If necessary the configuration hast to be set in the config.ini.
@type typ: string (FMS|ZVEI|POC)
@ -69,7 +69,7 @@ def run(typ,freq,data):
@keyword freq: frequency of the SDR Stick
@requires: If necessary the configuration hast to be set in the config.ini.
@return: nothing
@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.debug("cannot read config file", exc_info=True)
else: # Without config, plugin couldn't work
########## User Plugin CODE ##########
########## User Plugin CODE ##########
if typ == "FMS":
logging.warning("%s not supported", typ)
elif typ == "ZVEI":
@ -94,9 +94,9 @@ def run(typ,freq,data):
elif typ == "POC":
logging.warning("%s not supported", typ)
else:
logging.warning("Invalid Typ: %s", typ)
logging.warning("Invalid Typ: %s", typ)
########## User Plugin CODE ##########
except:
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
- press Pibrella button to stop alarm and reset the LEDs
@author: Jens Herrmann
@author: Jens Herrmann
BOSWatch: https://github.com/Schrolli91/BOSWatch
Pibrella: https://github.com/pimoroni/pibrella
@ -39,7 +39,7 @@ import json # for data
#
# Eventhandler for button
# will stop the alarm and reset the LEDs
#
#
def button_pressed(pin):
global siren_stopped
import pibrella
@ -75,15 +75,15 @@ pibrella.async_start('siren',siren)
#
# Main Program
#
try:
try:
# Logging
myLogger = logging.getLogger()
myLogger.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s [%(levelname)-8s] %(message)s', '%d.%m.%Y %H:%M:%S')
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
ch.setLevel(logging.DEBUG)
ch.setFormatter(formatter)
myLogger.addHandler(ch)
myLogger.addHandler(ch)
# Start TCP socket:
logging.debug("Start jsonSocketServer")
@ -91,7 +91,7 @@ try:
sock.bind((IP,PORT))
sock.listen(2)
logging.info("jsonSocketServer runs")
pibrella.light.green.on()
pibrella.light.green.on()
# our Alarm-RICs:
ric_alarm = [12345677, 12345676, 12345675]
@ -116,7 +116,7 @@ try:
if parsed_json['ric'] == "1234567":
logging.debug("POCSAG is alive")
pibrella.light.green.blink(1, 1)
elif int(parsed_json['ric']) in ric_alarm:
logging.debug("We have do to something")
if parsed_json['functionChar'] == "a":
@ -127,22 +127,22 @@ try:
pibrella.light.red.blink(1, 1)
# change variable to False to start the siren
siren_stopped = False
except KeyboardInterrupt:
logging.warning("Keyboard Interrupt")
logging.warning("Keyboard Interrupt")
except:
logging.exception("unknown error")
finally:
try:
logging.debug("socketServer shuting down")
sock.close()
logging.debug("socket closed")
logging.debug("exiting socketServer")
logging.debug("socket closed")
logging.debug("exiting socketServer")
except:
logging.warning("failed in clean-up routine")
finally:
logging.debug("close Logging")
logging.warning("failed in clean-up routine")
finally:
logging.debug("close Logging")
logging.info("socketServer exit()")
logging.shutdown()
ch.close()
exit(0)
exit(0)

View file

@ -2,8 +2,8 @@
##### Changing the init 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.
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.
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
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`).
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.
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.
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`.
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`.
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`
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`.
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`

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 %s\n", output.filename);
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
#in case of a double-tone for siren n-'D's are sended
ZVEI2: DDD
ZVEI2: DDDDD
ZVEI2: DDDDD

View file

@ -9,4 +9,4 @@ $tableFMS = "bos_fms";
$tableZVEI = "bos_zvei";
$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;">
<img src="gfx/logo.png" alt="BOSWatch"><br>
<a href="index.php?overview">[Übersicht]</a> - <a href="index.php?parser">[Parser]</a>
<br><br>
<img src="gfx/logo.png" alt="BOSWatch"><br>
<a href="index.php?overview">[<EFBFBD>bersicht]</a> - <a href="index.php?parser">[Parser]</a>
<br><br>
<?php
if(isset($_GET['overview']))
{
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/template.overview.php");
}
?>
?>
</div>
</body>
</html>
</html>

View file

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

View file

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

View file

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

View file

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