From ed08352f6723f06218e16e30f201f36b560d2a35 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 8 Dec 2015 18:57:53 +0800 Subject: [PATCH] gui: improve error handling --- artiq/gui/experiments.py | 16 ++++++++-------- artiq/gui/explorer.py | 24 ++++++++++++++++++------ 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/artiq/gui/experiments.py b/artiq/gui/experiments.py index b918d67ed..f33cc2c4d 100644 --- a/artiq/gui/experiments.py +++ b/artiq/gui/experiments.py @@ -202,8 +202,8 @@ class _ArgumentEditor(QtGui.QTreeWidget): try: arginfo = await self.manager.compute_arginfo(self.expurl) except: - logger.warning("Could not recompute argument '%s' of '%s'", - name, self.expurl, exc_info=True) + logger.error("Could not recompute argument '%s' of '%s'", + name, self.expurl, exc_info=True) argument = self.manager.get_submission_arguments(self.expurl)[name] procdesc = arginfo[name][0] @@ -362,8 +362,8 @@ class _ExperimentDock(dockarea.Dock): except: # May happen when experiment has been removed # from repository/explist - logger.warning("failed to submit '%s'", - self.expurl, exc_info=True) + logger.error("Failed to submit '%s'", + self.expurl, exc_info=True) def reqterm_clicked(self): try: @@ -371,8 +371,8 @@ class _ExperimentDock(dockarea.Dock): except: # May happen when experiment has been removed # from repository/explist - logger.warning("failed to request termination of instances of '%s'", - self.expurl, exc_info=True) + logger.error("Failed to request termination of instances of '%s'", + self.expurl, exc_info=True) def _recompute_arguments_clicked(self): asyncio.ensure_future(self._recompute_arguments_task()) @@ -381,8 +381,8 @@ class _ExperimentDock(dockarea.Dock): try: arginfo = await self.manager.compute_arginfo(self.expurl) except: - logger.warning("Could not recompute arguments of '%s'", - self.expurl, exc_info=True) + logger.error("Could not recompute arguments of '%s'", + self.expurl, exc_info=True) self.manager.initialize_submission_arguments(self.expurl, arginfo) self.argeditor.deleteLater() diff --git a/artiq/gui/explorer.py b/artiq/gui/explorer.py index 91eb2a77e..777811a65 100644 --- a/artiq/gui/explorer.py +++ b/artiq/gui/explorer.py @@ -9,17 +9,22 @@ from pyqtgraph import LayoutWidget from artiq.gui.models import DictSyncTreeSepModel +logger = logging.getLogger(__name__) + + class _OpenFileDialog(QtGui.QDialog): def __init__(self, parent, exp_manager): QtGui.QDialog.__init__(self, parent=parent) self.setWindowTitle("Open file outside repository") + self.exp_manager = exp_manager + grid = QtGui.QGridLayout() self.setLayout(grid) grid.addWidget(QtGui.QLabel("Filename:"), 0, 0) - filename = QtGui.QLineEdit() - grid.addWidget(filename, 0, 1) + self.filename = QtGui.QLineEdit() + grid.addWidget(self.filename, 0, 1) buttons = QtGui.QDialogButtonBox( QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel) @@ -27,10 +32,17 @@ class _OpenFileDialog(QtGui.QDialog): buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) - def open_file(): - file = filename.text() - asyncio.ensure_future(exp_manager.open_file(file)) - self.accepted.connect(open_file) + self.accepted.connect(self.open_file) + + def open_file(self): + file = self.filename.text() + async def open_task(): + try: + await self.exp_manager.open_file(file) + except: + logger.error("Failed to open file '%s'", + file, exc_info=True) + asyncio.ensure_future(open_task()) class Model(DictSyncTreeSepModel):