mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-04-05 06:25:10 +00:00
rename globals. call to globalVars.
This commit is contained in:
parent
f8fcda94b6
commit
e938cdcd6d
27 changed files with 300 additions and 300 deletions
|
|
@ -36,7 +36,7 @@ def processAlarmHandler(typ, freq, data):
|
|||
@return: nothing
|
||||
@exception: Exception if starting a Thread failed
|
||||
"""
|
||||
if globals.config.getboolean("BOSWatch","processAlarmAsync") == True:
|
||||
if globalVars.config.getboolean("BOSWatch","processAlarmAsync") == True:
|
||||
logging.debug("starting processAlarm async")
|
||||
try:
|
||||
from threading import Thread
|
||||
|
|
@ -74,9 +74,9 @@ def processAlarm(typ, freq, data):
|
|||
# timestamp, to make sure, that all plugins use the same time
|
||||
data['timestamp'] = int(time.time())
|
||||
# Go to all plugins in pluginList
|
||||
for pluginName, plugin in globals.pluginList.items():
|
||||
for pluginName, plugin in globalVars.pluginList.items():
|
||||
# if enabled use RegEx-filter
|
||||
if globals.config.getint("BOSWatch","useRegExFilter"):
|
||||
if globalVars.config.getint("BOSWatch","useRegExFilter"):
|
||||
from includes import regexFilter
|
||||
if regexFilter.checkFilters(typ, data, pluginName, freq):
|
||||
logging.debug("call Plugin: %s", pluginName)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ def checkRTL():
|
|||
@exception: Exception when checkRTL throws an unexpected error
|
||||
"""
|
||||
try:
|
||||
rtlLog = open(globals.log_path+"rtl_fm.log","r").read()
|
||||
rtlLog = open(globalVars.log_path+"rtl_fm.log","r").read()
|
||||
if ("exiting" in rtlLog) or ("Failed to open" in rtlLog):
|
||||
logging.debug("\n%s", rtlLog)
|
||||
raise OSError("starting rtl_fm returns an error")
|
||||
|
|
@ -41,7 +41,7 @@ def checkMultimon():
|
|||
@exception: Exception when checkMultimon throws an unexpected error
|
||||
"""
|
||||
try:
|
||||
multimonLog = open(globals.log_path+"multimon.log","r").read()
|
||||
multimonLog = open(globalVars.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")
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ def decode(freq, decoded):
|
|||
logging.info("FMS:%s Status:%s Richtung:%s TSI:%s", fms_id[0:8], fms_status, fms_direction, fms_tsi)
|
||||
data = {"fms":fms_id[0:8], "status":fms_status, "direction":fms_direction, "directionText":fms_directionText, "tsi":fms_tsi, "description":fms_id[0:8]}
|
||||
# If enabled, look up description
|
||||
if globals.config.getint("FMS", "idDescribed"):
|
||||
if globalVars.config.getint("FMS", "idDescribed"):
|
||||
from includes import descriptionList
|
||||
data["description"] = descriptionList.getDescription("FMS", fms_id[0:8])
|
||||
# processing the alarm
|
||||
|
|
|
|||
|
|
@ -34,22 +34,22 @@ def isAllowed(poc_id):
|
|||
"""
|
||||
# 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"):
|
||||
if globalVars.config.get("POC", "allow_ric"):
|
||||
if poc_id in globalVars.config.get("POC", "allow_ric"):
|
||||
logging.info("RIC %s is allowed", poc_id)
|
||||
return True
|
||||
else:
|
||||
logging.info("RIC %s is not in the allowed list", poc_id)
|
||||
return False
|
||||
# 2.) If denied RIC, return False
|
||||
elif poc_id in globals.config.get("POC", "deny_ric"):
|
||||
elif poc_id in globalVars.config.get("POC", "deny_ric"):
|
||||
logging.info("RIC %s is denied by config.ini", poc_id)
|
||||
return False
|
||||
# 3.) Check Range, return False if outside def. range
|
||||
elif int(poc_id) < globals.config.getint("POC", "filter_range_start"):
|
||||
elif int(poc_id) < globalVars.config.getint("POC", "filter_range_start"):
|
||||
logging.info("RIC %s out of filter range (start)", poc_id)
|
||||
return False
|
||||
elif int(poc_id) > globals.config.getint("POC", "filter_range_end"):
|
||||
elif int(poc_id) > globalVars.config.getint("POC", "filter_range_end"):
|
||||
logging.info("RIC %s out of filter range (end)", poc_id)
|
||||
return False
|
||||
return True
|
||||
|
|
@ -111,7 +111,7 @@ def decode(freq, decoded):
|
|||
# Add function as character a-d to dataset
|
||||
data["functionChar"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d")
|
||||
# If enabled, look up description
|
||||
if globals.config.getint("POC", "idDescribed"):
|
||||
if globalVars.config.getint("POC", "idDescribed"):
|
||||
from includes import descriptionList
|
||||
data["description"] = descriptionList.getDescription("POC", poc_id)
|
||||
# processing the alarm
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ def decode(freq, decoded):
|
|||
logging.info("5-Ton: %s", zvei_id)
|
||||
data = {"zvei":zvei_id, "description":zvei_id}
|
||||
# If enabled, look up description
|
||||
if globals.config.getint("ZVEI", "idDescribed"):
|
||||
if globalVars.config.getint("ZVEI", "idDescribed"):
|
||||
from includes import descriptionList
|
||||
data["description"] = descriptionList.getDescription("ZVEI", zvei_id)
|
||||
# processing the alarm
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ def loadCSV(typ, idField):
|
|||
resultList = {}
|
||||
try:
|
||||
logging.debug("-- loading %s.csv", typ)
|
||||
with open(globals.script_path+'/csv/'+typ+'.csv') as csvfile:
|
||||
with open(globalVars.script_path+'/csv/'+typ+'.csv') as csvfile:
|
||||
# DictReader expected structure described in first line of csv-file
|
||||
reader = csv.DictReader(csvfile)
|
||||
for row in reader:
|
||||
|
|
@ -70,17 +70,17 @@ def loadDescriptionLists():
|
|||
try:
|
||||
logging.debug("loading description lists")
|
||||
|
||||
if globals.config.getint("FMS", "idDescribed"):
|
||||
if globalVars.config.getint("FMS", "idDescribed"):
|
||||
logging.debug("- load FMS description list")
|
||||
global fmsDescribtionList
|
||||
fmsDescribtionList = loadCSV("fms", "fms")
|
||||
|
||||
if globals.config.getint("ZVEI", "idDescribed"):
|
||||
if globalVars.config.getint("ZVEI", "idDescribed"):
|
||||
logging.debug("- load ZVEI description list")
|
||||
global zveiDescribtionList
|
||||
zveiDescribtionList = loadCSV("zvei", "zvei")
|
||||
|
||||
if globals.config.getint("POC", "idDescribed"):
|
||||
if globalVars.config.getint("POC", "idDescribed"):
|
||||
logging.debug("- load pocsag description list")
|
||||
global ricDescribtionList
|
||||
ricDescribtionList = loadCSV("poc", "ric")
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ def checkID(typ, id, msg=""):
|
|||
(xID, xTimestamp, xMsg) = 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"):
|
||||
logging.debug("-- previous id %s is within doubleFilter_ignore_time (%ss)", xID, globals.config.getint("BOSWatch", "doubleFilter_ignore_time"))
|
||||
if id == xID and timestamp < xTimestamp + globalVars.config.getint("BOSWatch", "doubleFilter_ignore_time"):
|
||||
logging.debug("-- previous id %s is within doubleFilter_ignore_time (%ss)", xID, globalVars.config.getint("BOSWatch", "doubleFilter_ignore_time"))
|
||||
# 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 globalVars.config.getint("BOSWatch", "doubleFilter_check_msg"):
|
||||
logging.debug("-- compare msg:")
|
||||
logging.debug("---- current msg: (%s)", msg.strip())
|
||||
logging.debug("---- previous msg: (%s)", xMsg)
|
||||
|
|
@ -69,6 +69,6 @@ def newEntry(id, msg = ""):
|
|||
logging.debug("Added %s to doubleList", id)
|
||||
|
||||
# now check if list has more than n entries:
|
||||
if len(doubleList) > globals.config.getint("BOSWatch", "doubleFilter_ignore_entries"):
|
||||
if len(doubleList) > globalVars.config.getint("BOSWatch", "doubleFilter_ignore_entries"):
|
||||
# we have to kill the oldest one
|
||||
doubleList.pop(0)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ def checkConfig(section=""):
|
|||
if section is not "": # read only data if section is given
|
||||
logging.debug("read [%s] from config file", section)
|
||||
|
||||
for key,val in globals.config.items(section):
|
||||
for key,val in globalVars.config.items(section):
|
||||
if ("password" in key) or ("apikey" in key):
|
||||
val = "***"
|
||||
logging.debug(" - %s = %s", key, val)
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ from includes import globalVars # Global variables
|
|||
|
||||
def loadPlugins():
|
||||
"""
|
||||
Load all plugins into globals.pluginList
|
||||
Load all plugins into globalVars.pluginList
|
||||
|
||||
@return: nothing
|
||||
@exception: Exception if insert into globals.pluginList failed
|
||||
@exception: Exception if insert into globalVars.pluginList failed
|
||||
"""
|
||||
try:
|
||||
logging.debug("loading plugins")
|
||||
|
|
@ -41,8 +41,8 @@ def loadPlugins():
|
|||
# Try to call the .onLoad() routine for all active plugins
|
||||
logging.debug("call %s.onLoad()", i["name"])
|
||||
plugin.onLoad()
|
||||
# Add it to globals.pluginList
|
||||
globals.pluginList[i["name"]] = plugin
|
||||
# Add it to globalVars.pluginList
|
||||
globalVars.pluginList[i["name"]] = plugin
|
||||
except:
|
||||
# call next plugin, if one has thrown an exception
|
||||
logging.error("error calling %s.onLoad()", i["name"])
|
||||
|
|
@ -63,7 +63,7 @@ def getPlugins():
|
|||
"""
|
||||
try:
|
||||
logging.debug("Search in plugin folder")
|
||||
PluginFolder = globals.script_path+"/plugins"
|
||||
PluginFolder = globalVars.script_path+"/plugins"
|
||||
plugins = []
|
||||
# Go to all Folders in the Plugin-Dir
|
||||
for i in os.listdir(PluginFolder):
|
||||
|
|
@ -75,7 +75,7 @@ def getPlugins():
|
|||
|
||||
# is the plugin enabled in the config-file?
|
||||
try:
|
||||
if globals.config.getint("Plugins", i):
|
||||
if globalVars.config.getint("Plugins", i):
|
||||
info = imp.find_module(i, [location])
|
||||
plugins.append({"name": i, "info": info})
|
||||
logging.debug("Plugin [ENABLED ] %s", i)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ def loadFilters():
|
|||
try:
|
||||
logging.debug("loading filters")
|
||||
# For each entry in config.ini [Filters] section
|
||||
for key,val in globals.config.items("Filters"):
|
||||
for key,val in globalVars.config.items("Filters"):
|
||||
logging.debug(" - %s = %s", key, val)
|
||||
filter = val.split(";")
|
||||
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ def printHeader(args):
|
|||
print " German BOS Information Script "
|
||||
print " by Bastian Schroll, Jens Herrmann "
|
||||
print ""
|
||||
print "SW Version: "+globals.versionNr
|
||||
print "Build Date: "+globals.buildDate
|
||||
print "SW Version: "+globalVars.versionNr
|
||||
print "Build Date: "+globalVars.buildDate
|
||||
print ""
|
||||
|
||||
print "Frequency: "+args.freq
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue