forked from M-Labs/artiq
1
0
Fork 0

dashboard: Restart applets if required

Restart applets that are already running if a ccb call updates their spec

Signed-off-by: Charles Baynham <charles.baynham@npl.co.uk>
This commit is contained in:
Charles Baynham 2020-05-24 12:31:38 +01:00 committed by Sébastien Bourdeauducq
parent 2538840756
commit 8858ba8095
1 changed files with 17 additions and 7 deletions

View File

@ -1,3 +1,4 @@
import asyncio
import logging import logging
from PyQt5 import QtCore, QtWidgets from PyQt5 import QtCore, QtWidgets
@ -149,15 +150,16 @@ class AppletsCCBDock(applets.AppletsDock):
corresponds to a single group. If ``group`` is ``None`` or an empty corresponds to a single group. If ``group`` is ``None`` or an empty
list, it corresponds to the root. list, it corresponds to the root.
``command`` gives the command line used to run the applet, as if it ``command`` gives the command line used to run the applet, as if it was
was started from a shell. The dashboard substitutes variables such as started from a shell. The dashboard substitutes variables such as
``$python`` that gives the complete file name of the Python ``$python`` that gives the complete file name of the Python interpreter
interpreter running the dashboard. running the dashboard.
If the name already exists (after following any specified groups), the If the name already exists (after following any specified groups), the
command or code of the existing applet with that name is replaced, and command or code of the existing applet with that name is replaced, and
the applet is shown at its previous position. If not, a new applet the applet is restarted and shown at its previous position. If not, a
entry is created and the applet is shown at any position on the screen. new applet entry is created and the applet is shown at any position on
the screen.
If the group(s) do not exist, they are created. If the group(s) do not exist, they are created.
@ -181,9 +183,17 @@ class AppletsCCBDock(applets.AppletsDock):
else: else:
spec = {"ty": "code", "code": code, "command": command} spec = {"ty": "code", "code": code, "command": command}
if applet is None: if applet is None:
logger.debug('Applet {} does not exist: creating'.format(name))
applet = self.new(name=name, spec=spec, parent=parent) applet = self.new(name=name, spec=spec, parent=parent)
else: else:
if spec != self.get_spec(applet):
logger.debug('Applet {} already exists: updating existing spec'.format(name))
self.set_spec(applet, spec) self.set_spec(applet, spec)
if applet.applet_dock:
asyncio.ensure_future(applet.applet_dock.restart())
else:
logger.debug('Applet {} already exists and no update required'.format(name))
if ccbp == "enable": if ccbp == "enable":
applet.setCheckState(0, QtCore.Qt.Checked) applet.setCheckState(0, QtCore.Qt.Checked)