From e02b42060bc7b71b225d4aaef8c7253656ff0218 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 26 Jan 2021 21:18:32 +0100 Subject: [PATCH] fixed error in logger causing rpi to think logging server is down --- build_deb.sh | 2 +- compLib/LogstashLogging.py | 10 ++++++---- compLib/Vision.py | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/build_deb.sh b/build_deb.sh index e76975d..70a7d21 100644 --- a/build_deb.sh +++ b/build_deb.sh @@ -32,7 +32,7 @@ fpm -s python --python-bin python3 --python-pip pip3 --python-package-name-prefi -d "python-pigpio" \ -d "python3-pigpio" \ -d "python3-numpy" \ - -v 0.0.3-6 -t deb setup.py + -v 0.0.3-7 -t deb setup.py # --deb-changelog changelog \ # --deb-upstream-changelog changelog \ diff --git a/compLib/LogstashLogging.py b/compLib/LogstashLogging.py index e8f3957..a57d90f 100644 --- a/compLib/LogstashLogging.py +++ b/compLib/LogstashLogging.py @@ -31,6 +31,7 @@ class StreamToLogger(object): """ Fake file-like stream object that redirects writes to a logger instance. """ + def __init__(self, textio, log_level=logging.INFO): self.logger = logging.getLogger('logstash') self.console = textio @@ -52,8 +53,8 @@ class StreamToLogger(object): try: - r = requests.head(f"http://{host}:{port}") - if r.status_code == 400: + r = requests.get(f"https://{host}:{port}") + if r.status_code == 401: logstash_logger.addHandler(asynchronousLogstashHandler) so = StreamToLogger(sys.stdout, logging.INFO) @@ -62,10 +63,11 @@ try: se = StreamToLogger(sys.stderr, logging.ERROR) sys.stderr = se else: - print(f"Could not connect to {host} -> {r.status_code}!") + print(f"Could not connect to {host} -> ERROR CODE: {r.status_code}!") except requests.exceptions.ConnectionError as identifier: print(f"Could not connect to {host}!") + print(f"Error loading logger was -> {identifier}") pass @@ -81,7 +83,7 @@ class Logging(object): :rtype: logging.Logger """ return logstash_logger - + @staticmethod def set_debug(): """Turns up the logging level of the library to debug. Should be used, when debugging with the diff --git a/compLib/Vision.py b/compLib/Vision.py index f567e6a..491d186 100644 --- a/compLib/Vision.py +++ b/compLib/Vision.py @@ -67,7 +67,8 @@ class __Streaming: :return: None """ with self.__lock: - self.__newest_frame = image.copy() + if image is not None: + self.__newest_frame = image.copy() def _newest_frame_generator(self): """