mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-25 03:08:27 +08:00
browser: dis/enable analyze/terminate buttons
This commit is contained in:
parent
633c36336c
commit
fe69712cc5
@ -176,7 +176,6 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
|
||||
self.layout.setRowStretch(0, 1)
|
||||
|
||||
self.options = {"log_level": logging.WARNING}
|
||||
self._worker = None
|
||||
self._run_task = None
|
||||
|
||||
log_level = QtWidgets.QComboBox()
|
||||
@ -206,6 +205,7 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
|
||||
QtWidgets.QSizePolicy.Expanding)
|
||||
self.layout.addWidget(run, 1, 4, 2, 1)
|
||||
run.clicked.connect(self.run_clicked)
|
||||
self._run = run
|
||||
|
||||
terminate = QtWidgets.QPushButton("Terminate")
|
||||
terminate.setIcon(QtWidgets.QApplication.style().standardIcon(
|
||||
@ -216,6 +216,8 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
|
||||
QtWidgets.QSizePolicy.Expanding)
|
||||
self.layout.addWidget(terminate, 3, 4)
|
||||
terminate.clicked.connect(self.terminate_clicked)
|
||||
terminate.setEnabled(False)
|
||||
self._terminate = terminate
|
||||
|
||||
def dragEnterEvent(self, ev):
|
||||
if ev.mimeData().hasFormat("text/uri-list"):
|
||||
@ -265,9 +267,6 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
|
||||
await self._recompute_arguments(arguments)
|
||||
|
||||
def run_clicked(self):
|
||||
if self._run_task is not None:
|
||||
logger.error("Analysis already started")
|
||||
return
|
||||
class_name, file = self.expurl.split("@", maxsplit=1)
|
||||
expid = {
|
||||
"repo_rev": "N/A",
|
||||
@ -280,32 +279,32 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
|
||||
for name, argument in self.arguments.items()},
|
||||
}
|
||||
self._run_task = asyncio.ensure_future(self._get_run_task(expid))
|
||||
self._run.setEnabled(False)
|
||||
self._terminate.setEnabled(True)
|
||||
|
||||
def done(fut):
|
||||
logger.info("Analysis done")
|
||||
self._run_task = None
|
||||
|
||||
self._run.setEnabled(True)
|
||||
self._terminate.setEnabled(False)
|
||||
self._run_task.add_done_callback(done)
|
||||
|
||||
async def _get_run_task(self, expid):
|
||||
self._worker = Worker(self._area.worker_handlers)
|
||||
worker = Worker(self._area.worker_handlers)
|
||||
try:
|
||||
await self._worker.build(rid=None, pipeline_name="browser",
|
||||
wd=os.path.abspath("."),
|
||||
expid=expid, priority=0)
|
||||
await self._worker.analyze()
|
||||
await worker.build(rid=None, pipeline_name="browser",
|
||||
wd=os.path.abspath("."),
|
||||
expid=expid, priority=0)
|
||||
await worker.analyze()
|
||||
except:
|
||||
# May happen when experiment has been removed
|
||||
# from repository/explist
|
||||
logger.error("Failed to run '%s'",
|
||||
self.expurl, exc_info=True)
|
||||
finally:
|
||||
await self._worker.close()
|
||||
self._worker = None
|
||||
await worker.close()
|
||||
|
||||
def terminate_clicked(self):
|
||||
if self._run_task is None:
|
||||
return
|
||||
try:
|
||||
self._run_task.cancel()
|
||||
except:
|
||||
|
Loading…
Reference in New Issue
Block a user