2015-04-03 15:55:10 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
# -*- coding: cp1252 -*-
|
2015-05-25 18:07:44 +02:00
|
|
|
#
|
|
|
|
|
"""
|
2015-05-28 13:51:20 +02:00
|
|
|
BOSWatch
|
2015-06-14 20:21:21 +02:00
|
|
|
Python script to receive and decode German BOS information with rtl_fm and multimon-NG
|
2015-05-28 13:51:20 +02:00
|
|
|
Through a simple plugin system, data can easily be transferred to other applications
|
2015-06-14 20:21:21 +02:00
|
|
|
For more information see the README.md
|
2015-05-28 13:51:20 +02:00
|
|
|
|
2015-05-31 12:40:43 +02:00
|
|
|
@author: Bastian Schroll
|
|
|
|
|
@author: Jens Herrmann
|
2015-05-28 13:51:20 +02:00
|
|
|
|
|
|
|
|
GitHUB: https://github.com/Schrolli91/BOSWatch
|
2015-05-25 18:07:44 +02:00
|
|
|
"""
|
2015-04-03 15:55:10 +02:00
|
|
|
|
2015-05-20 13:29:16 +02:00
|
|
|
import logging
|
2015-05-25 18:07:44 +02:00
|
|
|
import logging.handlers
|
2015-04-03 15:55:10 +02:00
|
|
|
|
2015-06-14 20:21:21 +02:00
|
|
|
import argparse # for parse the args
|
|
|
|
|
import ConfigParser # for parse the config file
|
|
|
|
|
import os # for log mkdir
|
|
|
|
|
import time # for timestamp
|
|
|
|
|
import subprocess # for starting rtl_fm and multimon-ng
|
2015-04-03 15:55:10 +02:00
|
|
|
|
2015-05-22 16:44:23 +02:00
|
|
|
from includes import globals # Global variables
|
2015-06-25 16:13:52 +02:00
|
|
|
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
|
2015-06-24 23:26:02 +02:00
|
|
|
|
2015-06-05 10:06:33 +02:00
|
|
|
|
|
|
|
|
#
|
2015-06-05 10:19:49 +02:00
|
|
|
# ArgParser
|
2015-06-14 20:21:21 +02:00
|
|
|
# Have to be before main program
|
2015-06-05 10:06:33 +02:00
|
|
|
#
|
|
|
|
|
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",
|
|
|
|
|
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)
|
|
|
|
|
parser.add_argument("-d", "--device", help="Device you want to use (Check with rtl_test)", type=int, default=0)
|
|
|
|
|
parser.add_argument("-e", "--error", help="Frequency-Error of your device in PPM", type=int, default=0)
|
|
|
|
|
parser.add_argument("-a", "--demod", help="Demodulation functions", choices=['FMS', 'ZVEI', 'POC512', 'POC1200', 'POC2400'], required=True, nargs="+")
|
|
|
|
|
parser.add_argument("-s", "--squelch", help="Level of squelch", type=int, default=0)
|
2015-06-25 17:10:31 +02:00
|
|
|
parser.add_argument("-u", "--usevarlog", help="Use '/var/log/boswatch' for logfiles instead of subdir 'log' in BOSWatch directory", action="store_true")
|
2015-06-05 10:06:33 +02:00
|
|
|
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")
|
2015-06-29 22:31:34 +02:00
|
|
|
# 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")
|
2015-06-05 10:06:33 +02:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
except SystemExit:
|
2015-06-05 10:19:49 +02:00
|
|
|
# -h or --help called, exit right now
|
2015-06-05 10:06:33 +02:00
|
|
|
exit(0)
|
|
|
|
|
except:
|
2015-06-05 10:19:49 +02:00
|
|
|
print "cannot parsing the arguments"
|
2015-06-05 10:06:33 +02:00
|
|
|
|
|
|
|
|
|
2015-05-25 18:07:44 +02:00
|
|
|
#
|
2015-06-14 20:21:21 +02:00
|
|
|
# Main program
|
2015-05-25 18:07:44 +02:00
|
|
|
#
|
2015-04-19 19:21:35 +02:00
|
|
|
try:
|
2015-06-29 22:31:34 +02:00
|
|
|
# initialization:
|
|
|
|
|
rtl_fm = None
|
|
|
|
|
multimon_ng = None
|
|
|
|
|
|
2015-06-05 10:06:33 +02:00
|
|
|
try:
|
2015-05-25 18:07:44 +02:00
|
|
|
#
|
|
|
|
|
# Script-pathes
|
|
|
|
|
#
|
2015-05-20 19:28:10 +02:00
|
|
|
globals.script_path = os.path.dirname(os.path.abspath(__file__))
|
2015-06-25 17:10:31 +02:00
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Set log_path
|
|
|
|
|
#
|
|
|
|
|
if args.usevarlog:
|
|
|
|
|
globals.log_path = "/var/log/BOSWatch/"
|
|
|
|
|
else:
|
|
|
|
|
globals.log_path = globals.script_path+"/log/"
|
|
|
|
|
|
2015-05-25 18:07:44 +02:00
|
|
|
#
|
2015-06-14 20:21:21 +02:00
|
|
|
# If necessary create log-path
|
2015-05-25 18:07:44 +02:00
|
|
|
#
|
2015-06-25 17:10:31 +02:00
|
|
|
if not os.path.exists(globals.log_path):
|
|
|
|
|
os.mkdir(globals.log_path)
|
2015-06-05 10:06:33 +02:00
|
|
|
|
2015-05-25 18:07:44 +02:00
|
|
|
#
|
|
|
|
|
# Create new myLogger...
|
|
|
|
|
#
|
|
|
|
|
myLogger = logging.getLogger()
|
|
|
|
|
myLogger.setLevel(logging.DEBUG)
|
2015-06-14 20:21:21 +02:00
|
|
|
# set log string format
|
2015-06-05 21:49:51 +02:00
|
|
|
formatter = logging.Formatter('%(asctime)s - %(module)-15s [%(levelname)-8s] %(message)s', '%d.%m.%Y %H:%M:%S')
|
2015-06-14 20:21:21 +02:00
|
|
|
# create a file logger
|
2015-06-25 17:10:31 +02:00
|
|
|
fh = MyTimedRotatingFileHandler.MyTimedRotatingFileHandler(globals.log_path+"boswatch.log", "midnight", interval=1, backupCount=999)
|
2015-06-14 20:21:21 +02:00
|
|
|
# Starts with log level >= Debug
|
|
|
|
|
# will be changed with config.ini-param later
|
2015-05-25 18:07:44 +02:00
|
|
|
fh.setLevel(logging.DEBUG)
|
2015-05-20 19:28:10 +02:00
|
|
|
fh.setFormatter(formatter)
|
2015-05-25 18:07:44 +02:00
|
|
|
myLogger.addHandler(fh)
|
2015-06-14 20:21:21 +02:00
|
|
|
# create a display logger
|
2015-05-20 19:28:10 +02:00
|
|
|
ch = logging.StreamHandler()
|
2015-06-29 22:31:34 +02:00
|
|
|
# log level for display: Default: info
|
|
|
|
|
if args.verbose:
|
|
|
|
|
ch.setLevel(logging.DEBUG)
|
|
|
|
|
elif args.quiet:
|
|
|
|
|
ch.setLevel(logging.CRITICAL)
|
|
|
|
|
else:
|
|
|
|
|
ch.setLevel(logging.INFO)
|
2015-05-20 19:28:10 +02:00
|
|
|
ch.setFormatter(formatter)
|
2015-05-25 18:07:44 +02:00
|
|
|
myLogger.addHandler(ch)
|
2015-06-29 22:31:34 +02:00
|
|
|
|
2015-05-15 20:54:42 +02:00
|
|
|
except:
|
2015-06-29 22:31:34 +02:00
|
|
|
# we couldn't work without logging -> exit
|
|
|
|
|
logging.critical("cannot create logger")
|
|
|
|
|
logging.debug("cannot create logger", exc_info=True)
|
|
|
|
|
exit(1)
|
|
|
|
|
|
2015-06-05 10:19:49 +02:00
|
|
|
# initialization of the logging was fine, continue...
|
2015-06-29 22:31:34 +02:00
|
|
|
try:
|
|
|
|
|
#
|
|
|
|
|
# Clear the logfiles
|
|
|
|
|
#
|
|
|
|
|
fh.doRollover()
|
|
|
|
|
rtl_log = open(globals.log_path+"rtl_fm.log", "w")
|
|
|
|
|
mon_log = open(globals.log_path+"multimon.log", "w")
|
|
|
|
|
rtl_log.write("")
|
|
|
|
|
mon_log.write("")
|
|
|
|
|
rtl_log.close()
|
|
|
|
|
mon_log.close()
|
|
|
|
|
logging.debug("BOSWatch has started")
|
|
|
|
|
logging.debug("Logfiles cleared")
|
|
|
|
|
except:
|
|
|
|
|
# It's an error, but we could work without that stuff...
|
|
|
|
|
logging.error("cannot clear Logfiles")
|
|
|
|
|
logging.debug("cannot clear Logfiles", exc_info=True)
|
|
|
|
|
pass
|
2015-05-20 19:48:46 +02:00
|
|
|
|
2015-06-29 22:31:34 +02:00
|
|
|
try:
|
|
|
|
|
#
|
|
|
|
|
# For debug display/log args
|
|
|
|
|
#
|
|
|
|
|
if args.test:
|
|
|
|
|
logging.debug(" - We are in Test-Mode!")
|
2015-06-05 10:06:33 +02:00
|
|
|
|
2015-06-29 22:31:34 +02:00
|
|
|
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 "
|
|
|
|
|
logging.debug(" - Demod: FMS")
|
|
|
|
|
if "ZVEI" in args.demod:
|
|
|
|
|
demodulation += "-a ZVEI2 "
|
|
|
|
|
logging.debug(" - Demod: ZVEI")
|
|
|
|
|
if "POC512" in args.demod:
|
|
|
|
|
demodulation += "-a POCSAG512 "
|
|
|
|
|
logging.debug(" - Demod: POC512")
|
|
|
|
|
if "POC1200" in args.demod:
|
|
|
|
|
demodulation += "-a POCSAG1200 "
|
|
|
|
|
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)
|
2015-06-05 10:06:33 +02:00
|
|
|
|
2015-06-29 22:31:34 +02:00
|
|
|
if not args.quiet: #only if not quiet mode
|
|
|
|
|
from includes import shellHeader
|
|
|
|
|
shellHeader.printHeader(args)
|
|
|
|
|
|
|
|
|
|
if args.test:
|
|
|
|
|
logging.warning("!!! We are in Test-Mode !!!")
|
|
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
# we couldn't work without config -> exit
|
|
|
|
|
logging.critical("cannot display/log args")
|
|
|
|
|
logging.debug("cannot display/log args", exc_info=True)
|
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
#
|
|
|
|
|
# Read config.ini
|
|
|
|
|
#
|
|
|
|
|
logging.debug("reading config file")
|
|
|
|
|
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:
|
|
|
|
|
logging.debug(" - BOSWatch:")
|
|
|
|
|
for key,val in globals.config.items("BOSWatch"):
|
|
|
|
|
logging.debug(" -- %s = %s", key, val)
|
|
|
|
|
logging.debug(" - FMS:")
|
|
|
|
|
for key,val in globals.config.items("FMS"):
|
|
|
|
|
logging.debug(" -- %s = %s", key, val)
|
|
|
|
|
logging.debug(" - ZVEI:")
|
|
|
|
|
for key,val in globals.config.items("ZVEI"):
|
|
|
|
|
logging.debug(" -- %s = %s", key, val)
|
|
|
|
|
logging.debug(" - POC:")
|
|
|
|
|
for key,val in globals.config.items("POC"):
|
|
|
|
|
logging.debug(" -- %s = %s", key, val)
|
|
|
|
|
except:
|
|
|
|
|
# we couldn't work without config -> exit
|
|
|
|
|
logging.critical("cannot read config file")
|
|
|
|
|
logging.debug("cannot read config file", exc_info=True)
|
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
|
|
# initialization was fine, continue with main program...
|
|
|
|
|
try:
|
|
|
|
|
#
|
|
|
|
|
# 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"))
|
|
|
|
|
logging.debug("set backupCount of fileHandler to: %s", globals.config.getint("BOSWatch","backupCount"))
|
|
|
|
|
fh.setBackupCount(globals.config.getint("BOSWatch","backupCount"))
|
|
|
|
|
except:
|
|
|
|
|
# It's an error, but we could work without that stuff...
|
|
|
|
|
logging.error("cannot set loglevel of fileHandler")
|
|
|
|
|
logging.debug("cannot set loglevel of fileHandler", exc_info=True)
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Load plugins
|
|
|
|
|
#
|
|
|
|
|
from includes import pluginLoader
|
|
|
|
|
pluginLoader.loadPlugins()
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Load filters
|
|
|
|
|
#
|
|
|
|
|
if globals.config.getboolean("BOSWatch","useRegExFilter"):
|
|
|
|
|
from includes import filter
|
|
|
|
|
filter.loadFilters()
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Load description lists
|
|
|
|
|
#
|
|
|
|
|
if globals.config.getboolean("BOSWatch","useDescription"):
|
|
|
|
|
from includes import descriptionList
|
|
|
|
|
descriptionList.loadDescriptionLists()
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
#
|
|
|
|
|
# Start rtl_fm
|
|
|
|
|
#
|
|
|
|
|
if not args.test:
|
|
|
|
|
logging.debug("starting rtl_fm")
|
|
|
|
|
command = ""
|
|
|
|
|
if globals.config.has_option("BOSWatch","rtl_path"):
|
|
|
|
|
command = globals.config.get("BOSWatch","rtl_path")
|
|
|
|
|
command = command+"rtl_fm -d "+str(args.device)+" -f "+str(converter.freqToHz(args.freq))+" -M fm -s 22050 -p "+str(args.error)+" -E DC -F 0 -l "+str(args.squelch)+" -g 100"
|
|
|
|
|
rtl_fm = subprocess.Popen(command.split(),
|
|
|
|
|
#stdin=rtl_fm.stdout,
|
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
|
stderr=open(globals.log_path+"rtl_fm.log","a"),
|
|
|
|
|
shell=False)
|
|
|
|
|
# rtl_fm doesn't self-destruct, when an error occurs
|
|
|
|
|
# wait a moment to give the subprocess a chance to write the logfile
|
|
|
|
|
time.sleep(3)
|
|
|
|
|
rtlLog = open(globals.log_path+"rtl_fm.log","r").read()
|
|
|
|
|
if ("Failed" in rtlLog) or ("error" in rtlLog):
|
|
|
|
|
logging.debug("\n%s", rtlLog)
|
|
|
|
|
raise OSError("starting rtl_fm returns an error")
|
|
|
|
|
else:
|
|
|
|
|
logging.warning("!!! Test-Mode: rtl_fm not started !!!")
|
|
|
|
|
except:
|
|
|
|
|
# we couldn't work without rtl_fm -> exit
|
|
|
|
|
logging.critical("cannot start rtl_fm")
|
|
|
|
|
logging.debug("cannot start rtl_fm", exc_info=True)
|
|
|
|
|
exit(1)
|
2015-06-05 10:06:33 +02:00
|
|
|
|
2015-06-29 22:31:34 +02:00
|
|
|
# rtl_fm started, continue...
|
|
|
|
|
try:
|
|
|
|
|
#
|
|
|
|
|
# Start multimon
|
|
|
|
|
#
|
|
|
|
|
if not args.test:
|
|
|
|
|
logging.debug("starting multimon-ng")
|
|
|
|
|
command = ""
|
|
|
|
|
if globals.config.has_option("BOSWatch","multimon_path"):
|
|
|
|
|
command = globals.config.get("BOSWatch","multimon_path")
|
|
|
|
|
command = command+"multimon-ng "+str(demodulation)+" -f alpha -t raw /dev/stdin - "
|
|
|
|
|
multimon_ng = subprocess.Popen(command.split(),
|
|
|
|
|
stdin=rtl_fm.stdout,
|
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
|
stderr=open(globals.log_path+"multimon.log","a"),
|
|
|
|
|
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)
|
|
|
|
|
multimonLog = open(globals.log_path+"multimon.log","r").read()
|
|
|
|
|
if ("invalid" in multimonLog) or ("error" in multimonLog):
|
|
|
|
|
logging.debug("\n%s", multimonLog)
|
|
|
|
|
raise OSError("starting multimon-ng returns an error")
|
2015-06-05 10:06:33 +02:00
|
|
|
else:
|
2015-06-29 22:31:34 +02:00
|
|
|
logging.warning("!!! Test-Mode: multimon-ng not started !!!")
|
|
|
|
|
except:
|
|
|
|
|
# we couldn't work without multimon-ng -> exit
|
|
|
|
|
logging.critical("cannot start multimon-ng")
|
|
|
|
|
logging.debug("cannot start multimon-ng", exc_info=True)
|
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
|
|
# multimon-ng started, continue...
|
|
|
|
|
logging.debug("start decoding")
|
|
|
|
|
while True:
|
|
|
|
|
#
|
|
|
|
|
# Get decoded data from multimon-ng and call BOSWatch-decoder
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
# RAW Data from Multimon-NG
|
|
|
|
|
# ZVEI2: 25832
|
|
|
|
|
# FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST2=III(mit NA,ohneSIGNAL)) CRC correct\n'
|
|
|
|
|
# POCSAG1200: Address: 1234567 Function: 1 Alpha: Hello World
|
|
|
|
|
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"
|
|
|
|
|
#decoded = "FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=I (ohneNA,ohneSIGNAL)) CRC correct\n'"
|
|
|
|
|
#decoded = "FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 1=LST->FZG 2=I (ohneNA,ohneSIGNAL)) CRC correct\n'"
|
|
|
|
|
#decoded = "FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=II (ohneNA,mit SIGNAL)) 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 = "POCSAG1200: Address: 1234567 Function: 1 Alpha: Hello World"
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
from includes import decoder
|
|
|
|
|
decoder.decode(converter.freqToHz(args.freq), decoded)
|
|
|
|
|
|
2015-04-03 15:55:10 +02:00
|
|
|
except KeyboardInterrupt:
|
2015-05-20 13:29:16 +02:00
|
|
|
logging.warning("Keyboard Interrupt")
|
2015-06-24 23:26:02 +02:00
|
|
|
except SystemExit:
|
|
|
|
|
# SystemExitException is thrown if daemon was terminated
|
|
|
|
|
logging.warning("SystemExit received")
|
|
|
|
|
# only exit to call finally-block
|
2015-06-29 22:31:34 +02:00
|
|
|
exit()
|
2015-04-04 21:47:09 +02:00
|
|
|
except:
|
2015-05-20 13:29:16 +02:00
|
|
|
logging.exception("unknown error")
|
2015-04-04 23:32:51 +02:00
|
|
|
finally:
|
2015-05-15 20:54:42 +02:00
|
|
|
try:
|
2015-05-21 11:32:21 +02:00
|
|
|
logging.debug("BOSWatch shuting down")
|
2015-06-29 22:31:34 +02:00
|
|
|
if multimon_ng and 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)
|
|
|
|
|
rtl_fm.terminate()
|
|
|
|
|
rtl_fm.wait()
|
|
|
|
|
logging.debug("rtl_fm terminated")
|
2015-05-20 13:29:16 +02:00
|
|
|
logging.debug("exiting BOSWatch")
|
2015-05-15 20:54:42 +02:00
|
|
|
except:
|
2015-06-25 16:13:52 +02:00
|
|
|
logging.warning("failed in clean-up routine")
|
2015-06-29 22:31:34 +02:00
|
|
|
logging.debug("failed in clean-up routine", exc_info=True)
|
2015-06-24 23:26:02 +02:00
|
|
|
|
2015-05-26 07:19:24 +02:00
|
|
|
finally:
|
2015-05-25 18:07:44 +02:00
|
|
|
# Close Logging
|
2015-05-26 07:19:24 +02:00
|
|
|
logging.debug("close Logging")
|
2015-05-26 07:57:34 +02:00
|
|
|
logging.info("BOSWatch exit()")
|
2015-05-25 18:07:44 +02:00
|
|
|
logging.shutdown()
|
|
|
|
|
fh.close()
|
2015-06-29 22:31:34 +02:00
|
|
|
ch.close()
|