From ac5b6df77642f70b24c938771130848a68f3c215 Mon Sep 17 00:00:00 2001
From: Daniel <daniel@harvey>
Date: Thu, 5 Mar 2020 10:55:47 +0100
Subject: [PATCH] ENH: Graceful fail if db.Info() cannot connect to server.

---
 src/caosdb/common/models.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py
index 045c5002..84cdb96b 100644
--- a/src/caosdb/common/models.py
+++ b/src/caosdb/common/models.py
@@ -45,7 +45,8 @@ from caosdb.configuration import get_config
 from caosdb.connection.connection import get_connection
 from caosdb.connection.encode import MultipartParam, multipart_encode
 from caosdb.exceptions import (AmbiguityException, AuthorizationException,
-                               CaosDBException, ConsistencyError,
+                               CaosDBException, ConnectionException,
+                               ConsistencyError,
                                EntityDoesNotExistError, EntityError,
                                EntityHasNoDatatypeError, TransactionError,
                                UniqueNamesError, UnqualifiedParentsError,
@@ -3454,7 +3455,12 @@ class Info():
 
     def sync(self):
         c = get_connection()
-        http_response = c.retrieve(["Info"])
+        try:
+            http_response = c.retrieve(["Info"])
+        except ConnectionException as conn_e:
+            print(conn_e)
+            return
+
         xml = etree.fromstring(http_response.read())
 
         for e in xml:
-- 
GitLab