2015-07-01 22:31:20 +02:00
|
|
|
#!/usr/bin/python
|
2015-07-13 10:19:45 +02:00
|
|
|
# -*- coding: UTF-8 -*-
|
2015-07-01 22:31:20 +02:00
|
|
|
#
|
|
|
|
|
"""
|
|
|
|
|
Functions for checking the subprocesses rtl_fm and multimon-ng
|
|
|
|
|
Used in boswatch.py at startup and designated for watching-service
|
|
|
|
|
|
2015-07-02 09:02:49 +02:00
|
|
|
@author: Jens Herrmann
|
2015-07-01 22:31:20 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
2016-10-03 11:56:27 +02:00
|
|
|
from includes import globalVars # Global variables
|
2015-07-01 22:31:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def checkRTL():
|
|
|
|
|
"""
|
|
|
|
|
check startup of rtl_fm
|
|
|
|
|
|
|
|
|
|
@exception: OSError when rtl_fm returns an error
|
|
|
|
|
@exception: Exception when checkRTL throws an unexpected error
|
|
|
|
|
"""
|
|
|
|
|
try:
|
2016-10-03 12:02:18 +02:00
|
|
|
rtlLog = open(globalVars.log_path+"rtl_fm.log","r").read()
|
2015-07-01 22:31:20 +02:00
|
|
|
if ("exiting" in rtlLog) or ("Failed to open" in rtlLog):
|
|
|
|
|
logging.debug("\n%s", rtlLog)
|
|
|
|
|
raise OSError("starting rtl_fm returns an error")
|
|
|
|
|
except OSError:
|
|
|
|
|
raise
|
|
|
|
|
except:
|
|
|
|
|
# we couldn't work without rtl_fm
|
|
|
|
|
logging.critical("cannot check rtl_fm.log")
|
|
|
|
|
logging.debug("cannot check rtl_fm.log", exc_info=True)
|
|
|
|
|
raise
|
2015-07-02 09:02:49 +02:00
|
|
|
|
2015-07-01 22:31:20 +02:00
|
|
|
def checkMultimon():
|
|
|
|
|
"""
|
|
|
|
|
check startup of multimon-ng
|
|
|
|
|
|
|
|
|
|
@exception: OSError when multimon-ng returns an error
|
|
|
|
|
@exception: Exception when checkMultimon throws an unexpected error
|
|
|
|
|
"""
|
|
|
|
|
try:
|
2016-10-03 12:02:18 +02:00
|
|
|
multimonLog = open(globalVars.log_path+"multimon.log","r").read()
|
2015-07-01 22:31:20 +02:00
|
|
|
if ("invalid" in multimonLog) or ("error" in multimonLog):
|
|
|
|
|
logging.debug("\n%s", multimonLog)
|
|
|
|
|
raise OSError("starting multimon-ng returns an error")
|
|
|
|
|
except OSError:
|
|
|
|
|
raise
|
|
|
|
|
except:
|
|
|
|
|
# we couldn't work without multimon-ng
|
|
|
|
|
logging.critical("cannot check multimon.log")
|
|
|
|
|
logging.debug("cannot check multimon.log", exc_info=True)
|
2015-07-02 09:02:49 +02:00
|
|
|
raise
|