More connection tests + check if hash is not None on gui start

This commit is contained in:
2015-12-20 10:05:12 +05:30
parent 3377884900
commit b7f7f22d89
+15 -8
View File
@@ -34,16 +34,24 @@ class Controller(htmlPy.Object):
@htmlPy.Slot() @htmlPy.Slot()
def redraw(self): def redraw(self):
# from main import app as app_gui
print(self.app_gui.dir_name)
redis_db = redis.StrictRedis(host='localhost', port=REDIS_PORT, db=0) redis_db = redis.StrictRedis(host='localhost', port=REDIS_PORT, db=0)
# make sure that this is correct redis db
try: try:
assert redis_db.ping()
except redis.exceptions.ConnectionError:
raise redis.exceptions.ConnectionError("Cant connect to this socket. Is redis running?\n"
"Couldnt start pytest_status_gui")
except AssertionError:
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")
try:
# make sure that this is correct redis db
assert redis_db.get("PYTEST_STATUS_DB") == "1" assert redis_db.get("PYTEST_STATUS_DB") == "1"
except AssertionError, e: except AssertionError:
print("Got redis db, but it is not related to pytest status") raise redis.exceptions.ConnectionError("Redis is running on this port, but it is not related to pytest status\n"
raise e "Couldnt start pytest_status_gui")
dir_name = self.app_gui.dir_name dir_name = self.app_gui.dir_name
hash_dir_name = redis_db.hget("directories_to_hash", dir_name) hash_dir_name = redis_db.hget("directories_to_hash", dir_name)
@@ -72,7 +80,6 @@ class Controller(htmlPy.Object):
dict_state["skip"] = redis_db.lrange("{hash_a}_skip".format(hash_a=hash_dir_name), 0, -1) dict_state["skip"] = redis_db.lrange("{hash_a}_skip".format(hash_a=hash_dir_name), 0, -1)
if (not self.last_state) or (self.last_state != dict_state): if (not self.last_state) or (self.last_state != dict_state):
print("called redraw")
self.app_gui.html = render_template(self.app_gui, "index.html", dict_state) self.app_gui.html = render_template(self.app_gui, "index.html", dict_state)
self.last_state = dict_state self.last_state = dict_state