Skip to content

Commit 6fb605f

Browse files
committed
enh: handle missing network connection better
1 parent 8de2faf commit 6fb605f

4 files changed

Lines changed: 23 additions & 9 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,6 @@ _dev_*.py
115115
# QtCreator temporary files
116116
*.ui.autosave
117117
*.png~
118+
119+
# line_profiler
120+
*.lprof

dcoraid/gui/dbview/filter_chain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def on_add_datasets_to_collection(self):
145145
"""Add all datasets currently selected to a collection
146146
147147
Displays a dialog where the user can choose a collection
148-
she has write-access to.
148+
they have write-access to.
149149
"""
150150
# get current selection
151151
dataset_ids = self.fw_datasets.get_entry_identifiers(selected=True)

dcoraid/gui/main.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def __init__(self, *args, **kwargs):
4949
self._update_thread = None
5050
self._update_worker = None
5151

52+
self.database = None
53+
5254
# Settings are stored in the .ini file format. Even though
5355
# `self.settings` may return integer/bool in the same session,
5456
# in the next session, it will reliably return strings. Lists
@@ -152,7 +154,14 @@ def __init__(self, *args, **kwargs):
152154
@QtCore.pyqtSlot(bool)
153155
def check_update_database(self, reset=False, force=False):
154156
doit = False
155-
if force:
157+
if not self.database:
158+
QtWidgets.QMessageBox.critical(
159+
self,
160+
"No connection",
161+
"Database could not be initialized. Please make sure "
162+
"your are connected to the network."
163+
)
164+
elif force:
156165
doit = True
157166
else:
158167
if (self.database.local_timestamp < time.time() - 24*3600

dcoraid/gui/panel_find_data/widget_find_data.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ def __init__(self, *args, **kwargs):
3737

3838
@QtCore.pyqtSlot()
3939
def on_search(self):
40-
self.find_main_window().check_update_database()
41-
self.setCursor(QtCore.Qt.CursorShape.WaitCursor)
42-
dbextract = self.database.search_dataset(
43-
self.lineEdit_search.text(),
44-
limit=self.spinBox_public_rows.value())
45-
self.public_filter_chain.set_db_extract(dbextract)
46-
self.setCursor(QtCore.Qt.CursorShape.ArrowCursor)
40+
mv = self.find_main_window()
41+
mv.check_update_database()
42+
if mv.database:
43+
self.setCursor(QtCore.Qt.CursorShape.WaitCursor)
44+
dbextract = self.database.search_dataset(
45+
self.lineEdit_search.text(),
46+
limit=self.spinBox_public_rows.value())
47+
self.public_filter_chain.set_db_extract(dbextract)
48+
self.setCursor(QtCore.Qt.CursorShape.ArrowCursor)
4749

4850
@QtCore.pyqtSlot()
4951
def on_update_db(self):

0 commit comments

Comments
 (0)