From 6e011301d41bca2375f9583fe23db8d686dc9b91 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Thu, 11 Jan 2018 13:01:27 +0100 Subject: [PATCH] fix some typos and other --- boswatch/decoder/fms.py | 2 +- boswatch/descriptor/descriptor.py | 8 ++++---- boswatch/network/client.py | 3 +++ boswatch/utils/paths.py | 11 ++++++++--- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/boswatch/decoder/fms.py b/boswatch/decoder/fms.py index 3b69bcf..79634b2 100644 --- a/boswatch/decoder/fms.py +++ b/boswatch/decoder/fms.py @@ -63,7 +63,7 @@ class Fms: bwPacket.set("vehicle", vehicle) bwPacket.set("status", status) bwPacket.set("direction", direction) - bwPacket.set("cirectionText", directionText) + bwPacket.set("directionText", directionText) bwPacket.set("tacticalInfo", tacticalInfo) logging.debug(bwPacket) diff --git a/boswatch/descriptor/descriptor.py b/boswatch/descriptor/descriptor.py index ed0970c..cd93393 100644 --- a/boswatch/descriptor/descriptor.py +++ b/boswatch/descriptor/descriptor.py @@ -66,21 +66,21 @@ class DescriptionList: logging.debug("create new descriptionList") self._descriptionList = {} - def getShortDescription(self, id): + def getShortDescription(self, checkId): """!Returns the short description of given id @return short description or empty string""" try: - return self._descriptionList[str(id)]["shortDescription"] + return self._descriptionList[str(checkId)]["shortDescription"] except: return "" - def getLongDescription(self, id): + def getLongDescription(self, checkId): """!Returns the long description of given id @return long description or empty string""" try: - return self._descriptionList[str(id)]["longDescription"] + return self._descriptionList[str(checkId)]["longDescription"] except: return "" diff --git a/boswatch/network/client.py b/boswatch/network/client.py index 3734f25..c7ba4d8 100644 --- a/boswatch/network/client.py +++ b/boswatch/network/client.py @@ -82,6 +82,9 @@ class TCPClient: except AttributeError: logging.error("cannot transmit - no connection established") return False + except ConnectionResetError: + logging.error("cannot transmit - host closed connection") + return False except: # pragma: no cover logging.exception("error while transmitting") return False diff --git a/boswatch/utils/paths.py b/boswatch/utils/paths.py index d563123..040a930 100644 --- a/boswatch/utils/paths.py +++ b/boswatch/utils/paths.py @@ -29,15 +29,20 @@ BIN_PATH = ROOT_PATH + "/_bin/" TEST_PATH = ROOT_PATH + "/test/" -def createIfNotExist(dirPath): +def ifFileExist(filePath): + pass + + +def makeDirIfNotExist(dirPath): """!Checks if an directory is existing and create it if not @param dirPath: Path of the directory - @return Path of the directory""" + @return Path of the directory or False""" try: if not os.path.exists(dirPath): os.mkdir(dirPath) logging.debug("directory created: %s", dirPath) + return dirPath except: logging.exception("error by creating a directory: %s", dirPath) - return dirPath + return False