forked from M-Labs/artiq
1
0
Fork 0

gui: improve error handling

This commit is contained in:
Sebastien Bourdeauducq 2015-12-08 18:57:53 +08:00
parent 0da89557da
commit ed08352f67
2 changed files with 26 additions and 14 deletions

View File

@ -202,8 +202,8 @@ class _ArgumentEditor(QtGui.QTreeWidget):
try: try:
arginfo = await self.manager.compute_arginfo(self.expurl) arginfo = await self.manager.compute_arginfo(self.expurl)
except: except:
logger.warning("Could not recompute argument '%s' of '%s'", logger.error("Could not recompute argument '%s' of '%s'",
name, self.expurl, exc_info=True) name, self.expurl, exc_info=True)
argument = self.manager.get_submission_arguments(self.expurl)[name] argument = self.manager.get_submission_arguments(self.expurl)[name]
procdesc = arginfo[name][0] procdesc = arginfo[name][0]
@ -362,8 +362,8 @@ class _ExperimentDock(dockarea.Dock):
except: except:
# May happen when experiment has been removed # May happen when experiment has been removed
# from repository/explist # from repository/explist
logger.warning("failed to submit '%s'", logger.error("Failed to submit '%s'",
self.expurl, exc_info=True) self.expurl, exc_info=True)
def reqterm_clicked(self): def reqterm_clicked(self):
try: try:
@ -371,8 +371,8 @@ class _ExperimentDock(dockarea.Dock):
except: except:
# May happen when experiment has been removed # May happen when experiment has been removed
# from repository/explist # from repository/explist
logger.warning("failed to request termination of instances of '%s'", logger.error("Failed to request termination of instances of '%s'",
self.expurl, exc_info=True) self.expurl, exc_info=True)
def _recompute_arguments_clicked(self): def _recompute_arguments_clicked(self):
asyncio.ensure_future(self._recompute_arguments_task()) asyncio.ensure_future(self._recompute_arguments_task())
@ -381,8 +381,8 @@ class _ExperimentDock(dockarea.Dock):
try: try:
arginfo = await self.manager.compute_arginfo(self.expurl) arginfo = await self.manager.compute_arginfo(self.expurl)
except: except:
logger.warning("Could not recompute arguments of '%s'", logger.error("Could not recompute arguments of '%s'",
self.expurl, exc_info=True) self.expurl, exc_info=True)
self.manager.initialize_submission_arguments(self.expurl, arginfo) self.manager.initialize_submission_arguments(self.expurl, arginfo)
self.argeditor.deleteLater() self.argeditor.deleteLater()

View File

@ -9,17 +9,22 @@ from pyqtgraph import LayoutWidget
from artiq.gui.models import DictSyncTreeSepModel from artiq.gui.models import DictSyncTreeSepModel
logger = logging.getLogger(__name__)
class _OpenFileDialog(QtGui.QDialog): class _OpenFileDialog(QtGui.QDialog):
def __init__(self, parent, exp_manager): def __init__(self, parent, exp_manager):
QtGui.QDialog.__init__(self, parent=parent) QtGui.QDialog.__init__(self, parent=parent)
self.setWindowTitle("Open file outside repository") self.setWindowTitle("Open file outside repository")
self.exp_manager = exp_manager
grid = QtGui.QGridLayout() grid = QtGui.QGridLayout()
self.setLayout(grid) self.setLayout(grid)
grid.addWidget(QtGui.QLabel("Filename:"), 0, 0) grid.addWidget(QtGui.QLabel("Filename:"), 0, 0)
filename = QtGui.QLineEdit() self.filename = QtGui.QLineEdit()
grid.addWidget(filename, 0, 1) grid.addWidget(self.filename, 0, 1)
buttons = QtGui.QDialogButtonBox( buttons = QtGui.QDialogButtonBox(
QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel) QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
@ -27,10 +32,17 @@ class _OpenFileDialog(QtGui.QDialog):
buttons.accepted.connect(self.accept) buttons.accepted.connect(self.accept)
buttons.rejected.connect(self.reject) buttons.rejected.connect(self.reject)
def open_file(): self.accepted.connect(self.open_file)
file = filename.text()
asyncio.ensure_future(exp_manager.open_file(file)) def open_file(self):
self.accepted.connect(open_file) 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): class Model(DictSyncTreeSepModel):