Merge branch 'develop' into dev-express-alarm

This commit is contained in:
Bastian Schroll 2017-10-03 15:08:57 +02:00 committed by GitHub
commit fa90ba10cc
8 changed files with 46 additions and 47 deletions

View file

@ -9,7 +9,7 @@
##### Removed
##### Fixed
- Schreibfehler in Service Readme [#313](https://github.com/Schrolli91/BOSWatch/issues/313)
- einige Code-Style Verbesserungen
- Einige Code-Style Verbesserungen [#310](https://github.com/Schrolli91/BOSWatch/pull/310)
##### Security

View file

@ -159,7 +159,6 @@ def convertToUTF8(inputString = ""):
raise
# End of exception UnicodeDecodeError: check given string is already UTF-8
pass
except:
logging.warning("error checking given string")

View file

@ -3,14 +3,14 @@
from xml.dom.minidom import parseString
try:
from http.client import HTTPSConnection
from http.client import HTTPSConnection
except ImportError:
from httplib import HTTPSConnection
from httplib import HTTPSConnection
try:
from urllib.parse import urlencode
from urllib.parse import urlencode
except ImportError:
from urllib import urlencode
from urllib import urlencode
__version__ = "1.0"
@ -55,10 +55,10 @@ takes 2 optional arguments:
def delkey(self, key):
"Removes a key (unregister ?)"
if type(key) == str:
if isinstance(key, str):
if key in self._apikey:
self._apikey.remove(key)
elif type(key) == list:
elif isinstance(key, list):
for k in key:
if key in self._apikey:
self._apikey.remove(k)
@ -71,7 +71,7 @@ takes 2 optional arguments:
def pushWithAPIKey(self, apikey=[], application="", event="", description="", url="", contenttype=None, priority=0, batch_mode=False, html=False):
"""Special Funktion"""
if apikey:
if type(apikey) == str:
if isinstance(apikey, str):
apikey = [apikey]
self._apikey = uniq(apikey)
return self.push(application, event, description, url, contenttype, priority, batch_mode, html)

View file

@ -51,7 +51,7 @@ didBackup=false
if [ -f $boswatchpath/BOSWatch/boswatch.py ]; then
echo "Old installation found!"
echo "A backup will be copied to $boswatchpath/old"
mkdir /tmp/boswatch
mv $boswatchpath/BOSWatch/* /tmp/boswatch/
didBackup=true
@ -61,7 +61,7 @@ fi
if [ -f $boswatchpath/boswatch.py ]; then
echo "Old installation found!"
echo "A backup will be copied to $boswatchpath/old"
mkdir /tmp/boswatch
mv $boswatchpath/* /tmp/boswatch/
didBackup=true

View file

@ -21,23 +21,23 @@ from includes import globalVars # Global variables
from includes.helper import configHandler
def isSignal(poc_id):
"""
@type poc_id: string
@param poc_id: POCSAG Ric
"""
@type poc_id: string
@param poc_id: POCSAG Ric
@requires: Configuration has to be set in the config.ini
@requires: Configuration has to be set in the config.ini
@return: True if the Ric is Signal, other False
@exception: none
"""
# If RIC is Signal return True, else False
if globalVars.config.get("POC", "netIdent_ric"):
if poc_id in globalVars.config.get("POC", "netIdent_ric"):
logging.info("RIC %s is net ident", poc_id)
return True
else:
logging.info("RIC %s is no net ident", poc_id)
return False
@return: True if the Ric is Signal, other False
@exception: none
"""
# If RIC is Signal return True, else False
if globalVars.config.get("POC", "netIdent_ric"):
if poc_id in globalVars.config.get("POC", "netIdent_ric"):
logging.info("RIC %s is net ident", poc_id)
return True
else:
logging.info("RIC %s is no net ident", poc_id)
return False
##
@ -87,7 +87,7 @@ def run(typ,freq,data):
if configHandler.checkConfig("MySQL"): #read and debug the config
try:
#
#
# Connect to MySQL
#
logging.debug("connect to MySQL")

View file

@ -58,7 +58,7 @@ def run(typ,freq,data):
"""
try:
if configHandler.checkConfig("Sms77"): #read and debug the config
# create an empty message an fill it with the required information
message = "Alarm"
if typ == "FMS":

View file

@ -71,8 +71,8 @@ def run(typ,freq,data):
# Replace special characters in data Strings for URL
#
for key in data:
if isinstance(data[key], basestring):
data[key] = urllib.quote(data[key])
if isinstance(data[key], basestring):
data[key] = urllib.quote(data[key])
#
# Get URLs
#

View file

@ -268,23 +268,23 @@ def run(typ,freq,data):
# nothing found
pass
# 3. lets look for ric prefixes in pocAPIKeyList
for prefixLength in reversed(range(6)):
ricPrefix = data['ric'][:prefixLength]
#fill the ric with stars
ricPrefix = ricPrefix.ljust(8,'*')
try:
xID = ricPrefix
# data structure: pocAPIKeyList[xID][i] = (xAPIKey, xPriority, xEventPrefix)
for i in range(len(pocAPIKeyList[xID])):
xEvent = event
(xAPIKey, xPriority, xEventPrefix) = pocAPIKeyList[xID][i]
if len(xEventPrefix) > 0:
xEvent = xEventPrefix + ": " + xEvent
response = nma.pushWithAPIKey(xAPIKey, application, xEvent, msg, priority=xPriority)
checkResponse(response, xAPIKey)
except KeyError:
# nothing found
pass
for prefixLength in reversed(range(6)):
ricPrefix = data['ric'][:prefixLength]
#fill the ric with stars
ricPrefix = ricPrefix.ljust(8,'*')
try:
xID = ricPrefix
# data structure: pocAPIKeyList[xID][i] = (xAPIKey, xPriority, xEventPrefix)
for i in range(len(pocAPIKeyList[xID])):
xEvent = event
(xAPIKey, xPriority, xEventPrefix) = pocAPIKeyList[xID][i]
if len(xEventPrefix) > 0:
xEvent = xEventPrefix + ": " + xEvent
response = nma.pushWithAPIKey(xAPIKey, application, xEvent, msg, priority=xPriority)
checkResponse(response, xAPIKey)
except KeyError:
# nothing found
pass
# end if "POC" in typ
# end if usecsv == True