From 09aae4a189db14120b81eda6a61b06a8a9189df0 Mon Sep 17 00:00:00 2001 From: Abhas Bhattacharya Date: Wed, 23 Dec 2015 11:07:01 +0530 Subject: [PATCH] Stop gui when cant connect to redis --- pytest_gui_status/status_gui/gui_backend.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pytest_gui_status/status_gui/gui_backend.py b/pytest_gui_status/status_gui/gui_backend.py index b7fad95..e4de37a 100644 --- a/pytest_gui_status/status_gui/gui_backend.py +++ b/pytest_gui_status/status_gui/gui_backend.py @@ -38,19 +38,22 @@ class Controller(htmlPy.Object): try: assert redis_db.ping() except redis.exceptions.ConnectionError: + self.app_gui.stop() raise redis.exceptions.ConnectionError("Cant connect to this socket. Is redis running?\n" - "Couldnt start pytest_status_gui") + "Stopping pytest_status_gui") except AssertionError: + self.app_gui.stop() raise redis.exceptions.ConnectionError("Cant connect to redis, something else seems to be running on this socket. " "Is redis running?\n" - "Couldnt start pytest_status_gui") + "Stopping pytest_status_gui") try: # make sure that this is correct redis db assert redis_db.get("PYTEST_STATUS_DB") == "1" except AssertionError: + self.app_gui.stop() raise redis.exceptions.ConnectionError("Redis is running on this port, but it is not related to pytest status\n" - "Couldnt start pytest_status_gui") + "Stopping pytest_status_gui") dir_name = self.app_gui.dir_name hash_dir_name = redis_db.hget("directories_to_hash", dir_name)