forked from M-Labs/artiq
gui/applets: use templates instead of formats
This commit is contained in:
parent
7e2e182315
commit
f530815305
|
@ -18,7 +18,8 @@ unreleased [2.x]
|
||||||
* The "GUI" has been renamed the "dashboard".
|
* The "GUI" has been renamed the "dashboard".
|
||||||
* When flashing NIST boards, use "-m nist_qcX" or "-m nist_clock" instead of
|
* When flashing NIST boards, use "-m nist_qcX" or "-m nist_clock" instead of
|
||||||
just "-m qcX" or "-m clock" (#290).
|
just "-m qcX" or "-m clock" (#290).
|
||||||
|
* Applet command lines now use templates (e.g. $python) instead of formats
|
||||||
|
(e.g. {python}).
|
||||||
|
|
||||||
|
|
||||||
unreleased [1.0rc3]
|
unreleased [1.0rc3]
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
import asyncio
|
import asyncio
|
||||||
import sys
|
import sys
|
||||||
|
import string
|
||||||
import shlex
|
import shlex
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
|
@ -108,25 +109,26 @@ class _AppletDock(QDockWidgetCloseDetect):
|
||||||
if self.starting_stopping:
|
if self.starting_stopping:
|
||||||
return
|
return
|
||||||
self.starting_stopping = True
|
self.starting_stopping = True
|
||||||
|
|
||||||
self.ipc = AppletIPCServer(self.datasets_sub)
|
|
||||||
if "{ipc_address}" not in self.command:
|
|
||||||
logger.warning("IPC address missing from command for %s",
|
|
||||||
self.applet_name)
|
|
||||||
command = self.command.format(
|
|
||||||
python=sys.executable.replace("\\", "\\\\"),
|
|
||||||
ipc_address=self.ipc.get_address().replace("\\", "\\\\")
|
|
||||||
)
|
|
||||||
logger.debug("starting command %s for %s", command, self.applet_name)
|
|
||||||
try:
|
try:
|
||||||
await self.ipc.create_subprocess(*shlex.split(command),
|
self.ipc = AppletIPCServer(self.datasets_sub)
|
||||||
start_new_session=True)
|
if "$ipc_address" not in self.command:
|
||||||
except:
|
logger.warning("IPC address missing from command for %s",
|
||||||
logger.warning("Applet %s failed to start", self.applet_name,
|
self.applet_name)
|
||||||
exc_info=True)
|
command_tpl = string.Template(self.command)
|
||||||
self.ipc.start(self.embed, self.fix_initial_size)
|
command = command_tpl.safe_substitute(
|
||||||
|
python=sys.executable.replace("\\", "\\\\"),
|
||||||
self.starting_stopping = False
|
ipc_address=self.ipc.get_address().replace("\\", "\\\\")
|
||||||
|
)
|
||||||
|
logger.info("starting command %s for %s", command, self.applet_name)
|
||||||
|
try:
|
||||||
|
await self.ipc.create_subprocess(*shlex.split(command),
|
||||||
|
start_new_session=True)
|
||||||
|
except:
|
||||||
|
logger.warning("Applet %s failed to start", self.applet_name,
|
||||||
|
exc_info=True)
|
||||||
|
self.ipc.start(self.embed, self.fix_initial_size)
|
||||||
|
finally:
|
||||||
|
self.starting_stopping = False
|
||||||
|
|
||||||
def embed(self, win_id):
|
def embed(self, win_id):
|
||||||
logger.debug("capturing window 0x%x for %s", win_id, self.applet_name)
|
logger.debug("capturing window 0x%x for %s", win_id, self.applet_name)
|
||||||
|
@ -175,20 +177,20 @@ class _AppletDock(QDockWidgetCloseDetect):
|
||||||
|
|
||||||
|
|
||||||
_templates = [
|
_templates = [
|
||||||
("Big number", "{python} -m artiq.applets.big_number "
|
("Big number", "$python -m artiq.applets.big_number "
|
||||||
"--embed {ipc_address} NUMBER_DATASET"),
|
"--embed $ipc_address NUMBER_DATASET"),
|
||||||
("Histogram", "{python} -m artiq.applets.plot_hist "
|
("Histogram", "$python -m artiq.applets.plot_hist "
|
||||||
"--embed {ipc_address} COUNTS_DATASET "
|
"--embed $ipc_address COUNTS_DATASET "
|
||||||
"--x BIN_BOUNDARIES_DATASET"),
|
"--x BIN_BOUNDARIES_DATASET"),
|
||||||
("XY", "{python} -m artiq.applets.plot_xy "
|
("XY", "$python -m artiq.applets.plot_xy "
|
||||||
"--embed {ipc_address} Y_DATASET --x X_DATASET "
|
"--embed $ipc_address Y_DATASET --x X_DATASET "
|
||||||
"--error ERROR_DATASET --fit FIT_DATASET"),
|
"--error ERROR_DATASET --fit FIT_DATASET"),
|
||||||
("XY + Histogram", "{python} -m artiq.applets.plot_xy_hist "
|
("XY + Histogram", "$python -m artiq.applets.plot_xy_hist "
|
||||||
"--embed {ipc_address} X_DATASET "
|
"--embed $ipc_address X_DATASET "
|
||||||
"HIST_BIN_BOUNDARIES_DATASET "
|
"HIST_BIN_BOUNDARIES_DATASET "
|
||||||
"HISTS_COUNTS_DATASET"),
|
"HISTS_COUNTS_DATASET"),
|
||||||
("Image", "{python} -m artiq.applets.image "
|
("Image", "$python -m artiq.applets.image "
|
||||||
"--embed {ipc_address} IMG_DATASET"),
|
"--embed $ipc_address IMG_DATASET"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue