mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-01-05 00:00:03 +01:00
resolve some Code Style Problems
This commit is contained in:
parent
1877c7f367
commit
e3b3377f9e
|
|
@ -94,25 +94,25 @@ def loadDescriptionLists():
|
|||
#
|
||||
# public function for getting a description
|
||||
#
|
||||
def getDescription(typ, id):
|
||||
def getDescription(typ, data):
|
||||
"""
|
||||
Get description for id.
|
||||
Will return id if no description will be found.
|
||||
|
||||
@return: description as string
|
||||
"""
|
||||
resultStr = id;
|
||||
resultStr = data;
|
||||
logging.debug("look up description lists")
|
||||
try:
|
||||
if typ == "FMS":
|
||||
global fmsDescribtionList
|
||||
resultStr = fmsDescribtionList[id]
|
||||
resultStr = fmsDescribtionList[data]
|
||||
elif typ == "ZVEI":
|
||||
global zveiDescribtionList
|
||||
resultStr = zveiDescribtionList[id]
|
||||
resultStr = zveiDescribtionList[data]
|
||||
elif typ == "POC":
|
||||
global ricDescribtionList
|
||||
resultStr = ricDescribtionList[id]
|
||||
resultStr = ricDescribtionList[data]
|
||||
else:
|
||||
logging.warning("Invalid Typ: %s", typ)
|
||||
|
||||
|
|
@ -125,5 +125,5 @@ def getDescription(typ, id):
|
|||
logging.error("Error during look up description lists")
|
||||
logging.debug("Error during look up description lists", exc_info=True)
|
||||
|
||||
logging.debug(" - result for %s: %s", id, resultStr)
|
||||
logging.debug(" - result for %s: %s", data, resultStr)
|
||||
return resultStr
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ import time # timestamp for doublealarm
|
|||
from includes import globalVars # Global variables
|
||||
|
||||
#
|
||||
# ListStructure [0..n] = (ID, TimeStamp, msg)
|
||||
# ListStructure [0..n] = (Data, TimeStamp, msg)
|
||||
#
|
||||
doubleList = []
|
||||
|
||||
|
||||
def checkID(typ, id, msg=""):
|
||||
def checkID(typ, data, msg=""):
|
||||
"""
|
||||
check if id was called in the last x sec and n entries
|
||||
|
||||
|
|
@ -34,12 +34,12 @@ def checkID(typ, id, msg=""):
|
|||
global doubleList
|
||||
timestamp = int(time.time()) # Get Timestamp
|
||||
|
||||
logging.debug("checkID: %s (%s)", id, msg)
|
||||
logging.debug("checkID: %s (%s)", data, msg)
|
||||
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 + globalVars.config.getint("BOSWatch", "doubleFilter_ignore_time"):
|
||||
if data == 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 globalVars.config.getint("BOSWatch", "doubleFilter_check_msg"):
|
||||
|
|
@ -56,7 +56,7 @@ def checkID(typ, id, msg=""):
|
|||
return True
|
||||
|
||||
|
||||
def newEntry(id, msg = ""):
|
||||
def newEntry(data, msg = ""):
|
||||
"""
|
||||
new entry in double alarm list
|
||||
|
||||
|
|
@ -64,9 +64,9 @@ def newEntry(id, msg = ""):
|
|||
"""
|
||||
global doubleList
|
||||
timestamp = int(time.time()) # Get Timestamp
|
||||
doubleList.append((id, timestamp, msg.strip()))
|
||||
doubleList.append((data, timestamp, msg.strip()))
|
||||
|
||||
logging.debug("Added %s to doubleList", id)
|
||||
logging.debug("Added %s to doubleList", data)
|
||||
|
||||
# now check if list has more than n entries:
|
||||
if len(doubleList) > globalVars.config.getint("BOSWatch", "doubleFilter_ignore_entries"):
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import logging
|
|||
import time
|
||||
|
||||
|
||||
def curtime(format="%d.%m.%Y %H:%M:%S", timestamp=""):
|
||||
def curtime(timeStr="%d.%m.%Y %H:%M:%S", timestamp=""):
|
||||
"""
|
||||
Returns formated date and/or time
|
||||
see: https://docs.python.org/2/library/time.html#time.strftime
|
||||
|
|
@ -30,9 +30,9 @@ def curtime(format="%d.%m.%Y %H:%M:%S", timestamp=""):
|
|||
"""
|
||||
try:
|
||||
if timestamp == "":
|
||||
return time.strftime(format)
|
||||
return time.strftime(timeStr)
|
||||
else:
|
||||
return time.strftime(format, time.localtime(timestamp))
|
||||
return time.strftime(timeStr, time.localtime(timestamp))
|
||||
except:
|
||||
logging.warning("error in time-format-string")
|
||||
logging.debug("error in time-format-string", exc_info=True)
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ Yowsup-Plugin to dispatch POCSAG - messages to WhatsApp Numbers or Chats
|
|||
yowsup-Configuration has to be set in the config.ini
|
||||
"""
|
||||
|
||||
import logging
|
||||
import logging
|
||||
import subprocess
|
||||
import shlex
|
||||
import os
|
||||
|
||||
from includes import globalVars
|
||||
from includes import globalVars
|
||||
|
||||
from includes.helper import timeHandler
|
||||
from includes.helper import wildcardHandler
|
||||
|
|
@ -34,23 +34,23 @@ def run(typ,freq,data):
|
|||
sender = globalVars.config.get("yowsup", "sender")
|
||||
password = globalVars.config.get("yowsup", "password")
|
||||
devnull = open(os.devnull, "wb")
|
||||
|
||||
|
||||
if typ == "FMS":
|
||||
text = globalVars.config.get("yowsup","fms_message")
|
||||
text = wildcardHandler.replaceWildcards(text, data)
|
||||
text = wildcardHandler.replaceWildcards(text, data)
|
||||
cmd = 'yowsup-cli demos -l ' + sender + ':' + password + ' -s ' + empfaenger + ' "' + text + '" -M'
|
||||
subprocess.call(shlex.split(cmd), stdout=devnull, stderr=devnull)
|
||||
logging.debug("Message has been sent")
|
||||
elif typ == "ZVEI":
|
||||
text = globalVars.config.get("yowsup","zvei_message")
|
||||
text = wildcardHandler.replaceWildcards(text, data)
|
||||
text = wildcardHandler.replaceWildcards(text, data)
|
||||
cmd = 'yowsup-cli demos -l ' + sender + ':' + password + ' -s ' + empfaenger + ' "' + text + '" -M'
|
||||
subprocess.call(shlex.split(cmd), stdout=devnull, stderr=devnull)
|
||||
logging.debug("Message has been sent")
|
||||
elif typ == "POC":
|
||||
try:
|
||||
text = globalVars.config.get("yowsup","poc_message")
|
||||
text = wildcardHandler.replaceWildcards(text, data)
|
||||
text = wildcardHandler.replaceWildcards(text, data)
|
||||
cmd = 'yowsup-cli demos -l ' + sender + ':' + password + ' -s ' + empfaenger + ' "' + text + '" -M'
|
||||
subprocess.call(shlex.split(cmd), stdout=devnull, stderr=devnull)
|
||||
logging.debug("Message has been sent")
|
||||
|
|
|
|||
Loading…
Reference in a new issue