From 85895ab89b32555b92c16d1cd2650a38c65ac013 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sat, 18 Jun 2022 02:29:48 +0100 Subject: [PATCH] dashboard: Add cmdline option to load plugins on startup Together with m-labs/artiq#1916, this allows the user to integrate multiple argument UIs implemented in external libraries. --- artiq/frontend/artiq_dashboard.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/artiq/frontend/artiq_dashboard.py b/artiq/frontend/artiq_dashboard.py index a554f4717..1cdbac731 100755 --- a/artiq/frontend/artiq_dashboard.py +++ b/artiq/frontend/artiq_dashboard.py @@ -3,6 +3,7 @@ import argparse import asyncio import atexit +import importlib import os import logging import sys @@ -43,6 +44,9 @@ def get_argparser(): parser.add_argument( "--db-file", default=None, help="database file for local GUI settings") + parser.add_argument( + "-p", "--load-plugin", dest="plugin_modules", action="append", + help="Python module to load on startup") common_args.verbosity_args(parser) return parser @@ -95,6 +99,11 @@ def main(): args = get_argparser().parse_args() widget_log_handler = log.init_log(args, "dashboard") + # load any plugin modules first (to register argument_ui classes, etc.) + if args.plugin_modules: + for mod in args.plugin_modules: + importlib.import_module(mod) + if args.db_file is None: args.db_file = os.path.join(get_user_config_dir(), "artiq_dashboard_{server}_{port}.pyon".format(