mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-04-10 08:53:37 +00:00
reduce entries in globals.py
only entries for use in more than one .py-file have to stay here...
This commit is contained in:
parent
e26fc45313
commit
02efb9552a
4 changed files with 45 additions and 37 deletions
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
doubleFilter is the central function to filter out double alarms.
|
||||
|
|
@ -19,6 +19,8 @@ from includes import globals # Global variables
|
|||
#
|
||||
# ListStructure [0..n] = (ID, TimeStamp, msg)
|
||||
#
|
||||
doubleList = []
|
||||
|
||||
|
||||
def checkID(typ, id, msg=""):
|
||||
"""
|
||||
|
|
@ -29,11 +31,12 @@ def checkID(typ, id, msg=""):
|
|||
@return: True if check was OK
|
||||
@return: False if double was found
|
||||
"""
|
||||
global doubleList
|
||||
timestamp = int(time.time()) # Get Timestamp
|
||||
|
||||
logging.debug("checkID: %s (%s)", id, msg)
|
||||
for i in range(len(globals.doubleList)):
|
||||
(xID, xTimestamp, xMsg) = globals.doubleList[i]
|
||||
for i in range(len(doubleList)):
|
||||
(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"):
|
||||
|
|
@ -59,12 +62,13 @@ def newEntry(id, msg = ""):
|
|||
|
||||
@return: nothing
|
||||
"""
|
||||
global doubleList
|
||||
timestamp = int(time.time()) # Get Timestamp
|
||||
globals.doubleList.append((id, timestamp, msg.strip()))
|
||||
doubleList.append((id, timestamp, msg.strip()))
|
||||
|
||||
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"):
|
||||
if len(doubleList) > globals.config.getint("BOSWatch", "doubleFilter_ignore_entries"):
|
||||
# we have to kill the oldest one
|
||||
globals.doubleList.pop(0)
|
||||
doubleList.pop(0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue