From 4416378d21d9f265ce235ebf0f495b361af3e2ab Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 14 Nov 2019 11:42:31 +0800 Subject: [PATCH] frontend: add --version to common tools --- artiq/frontend/artiq_browser.py | 4 ++++ artiq/frontend/artiq_compile.py | 4 ++++ artiq/frontend/artiq_coremgmt.py | 4 ++++ artiq/frontend/artiq_dashboard.py | 4 ++++ artiq/frontend/artiq_ddb_template.py | 5 +++++ artiq/frontend/artiq_flash.py | 5 +++++ artiq/frontend/artiq_master.py | 4 ++++ artiq/frontend/artiq_run.py | 4 ++++ artiq/frontend/artiq_session.py | 5 ++++- 9 files changed, 38 insertions(+), 1 deletion(-) diff --git a/artiq/frontend/artiq_browser.py b/artiq/frontend/artiq_browser.py index da5bead60..e002cac83 100755 --- a/artiq/frontend/artiq_browser.py +++ b/artiq/frontend/artiq_browser.py @@ -9,6 +9,7 @@ import logging from PyQt5 import QtCore, QtGui, QtWidgets from quamash import QEventLoop +from artiq import __version__ as artiq_version from artiq import __artiq_dir__ as artiq_dir from artiq.tools import (add_common_args, atexit_register_coroutine, get_user_config_dir) @@ -21,6 +22,9 @@ logger = logging.getLogger(__name__) def get_argparser(): parser = argparse.ArgumentParser(description="ARTIQ Browser") + parser.add_argument("--version", action="version", + version="ARTIQ v{}".format(artiq_version), + help="print the ARTIQ version number") parser.add_argument("--db-file", default=None, help="database file for local browser settings " "(default: %(default)s)") diff --git a/artiq/frontend/artiq_compile.py b/artiq/frontend/artiq_compile.py index 2ebe0a657..1609971e0 100755 --- a/artiq/frontend/artiq_compile.py +++ b/artiq/frontend/artiq_compile.py @@ -4,6 +4,7 @@ import os, sys, logging, argparse from sipyco import common_args +from artiq import __version__ as artiq_version from artiq.master.databases import DeviceDB, DatasetDB from artiq.master.worker_db import DeviceManager, DatasetManager from artiq.language.environment import ProcessArgumentManager @@ -16,6 +17,9 @@ logger = logging.getLogger(__name__) def get_argparser(): parser = argparse.ArgumentParser(description="ARTIQ static compiler") + parser.add_argument("--version", action="version", + version="ARTIQ v{}".format(artiq_version), + help="print the ARTIQ version number") common_args.verbosity_args(parser) parser.add_argument("--device-db", default="device_db.py", diff --git a/artiq/frontend/artiq_coremgmt.py b/artiq/frontend/artiq_coremgmt.py index 5c7594cff..db420c971 100755 --- a/artiq/frontend/artiq_coremgmt.py +++ b/artiq/frontend/artiq_coremgmt.py @@ -5,6 +5,7 @@ import struct from sipyco import common_args +from artiq import __version__ as artiq_version from artiq.master.databases import DeviceDB from artiq.coredevice.comm_kernel import CommKernel from artiq.coredevice.comm_mgmt import CommMgmt @@ -14,6 +15,9 @@ from artiq.coredevice.profiler import CallgrindWriter def get_argparser(): parser = argparse.ArgumentParser(description="ARTIQ core device " "management tool") + parser.add_argument("--version", action="version", + version="ARTIQ v{}".format(artiq_version), + help="print the ARTIQ version number") common_args.verbosity_args(parser) parser.add_argument("--device-db", default="device_db.py", diff --git a/artiq/frontend/artiq_dashboard.py b/artiq/frontend/artiq_dashboard.py index 6af277019..d954b0190 100755 --- a/artiq/frontend/artiq_dashboard.py +++ b/artiq/frontend/artiq_dashboard.py @@ -13,6 +13,7 @@ from sipyco.pc_rpc import AsyncioClient, Client from sipyco.broadcast import Receiver from sipyco import common_args +from artiq import __version__ as artiq_version from artiq import __artiq_dir__ as artiq_dir, __version__ as artiq_version from artiq.tools import atexit_register_coroutine, get_user_config_dir from artiq.gui.models import ModelSubscriber @@ -23,6 +24,9 @@ from artiq.dashboard import (experiments, shortcuts, explorer, def get_argparser(): parser = argparse.ArgumentParser(description="ARTIQ Dashboard") + parser.add_argument("--version", action="version", + version="ARTIQ v{}".format(artiq_version), + help="print the ARTIQ version number") parser.add_argument( "-s", "--server", default="::1", help="hostname or IP of the master to connect to") diff --git a/artiq/frontend/artiq_ddb_template.py b/artiq/frontend/artiq_ddb_template.py index 48fda75a6..b561e69d9 100755 --- a/artiq/frontend/artiq_ddb_template.py +++ b/artiq/frontend/artiq_ddb_template.py @@ -7,6 +7,8 @@ import textwrap from collections import defaultdict from itertools import count +from artiq import __version__ as artiq_version + def process_header(output, description): if description["target"] != "kasli": @@ -473,6 +475,9 @@ def process(output, master_description, satellites): def main(): parser = argparse.ArgumentParser( description="ARTIQ device database template builder") + parser.add_argument("--version", action="version", + version="ARTIQ v{}".format(artiq_version), + help="print the ARTIQ version number") parser.add_argument("master_description", metavar="MASTER_DESCRIPTION", help="JSON system description file for the standalone or master node") parser.add_argument("-o", "--output", diff --git a/artiq/frontend/artiq_flash.py b/artiq/frontend/artiq_flash.py index f2dd3d727..495a3bd00 100755 --- a/artiq/frontend/artiq_flash.py +++ b/artiq/frontend/artiq_flash.py @@ -12,6 +12,7 @@ from collections import defaultdict from sipyco import common_args +from artiq import __version__ as artiq_version from artiq import __artiq_dir__ as artiq_dir from artiq.remoting import SSHClient, LocalClient from artiq.frontend.bit2bin import bit2bin @@ -42,6 +43,10 @@ Prerequisites: plugdev group: 'sudo adduser $USER plugdev' and re-login. """) + parser.add_argument("--version", action="version", + version="ARTIQ v{}".format(artiq_version), + help="print the ARTIQ version number") + common_args.verbosity_args(parser) parser.add_argument("-n", "--dry-run", diff --git a/artiq/frontend/artiq_master.py b/artiq/frontend/artiq_master.py index 373fd4da4..ff9014b50 100755 --- a/artiq/frontend/artiq_master.py +++ b/artiq/frontend/artiq_master.py @@ -12,6 +12,7 @@ from sipyco.logging_tools import Server as LoggingServer from sipyco.broadcast import Broadcaster from sipyco import common_args +from artiq import __version__ as artiq_version from artiq.tools import atexit_register_coroutine from artiq.master.log import log_args, init_log from artiq.master.databases import DeviceDB, DatasetDB @@ -25,6 +26,9 @@ logger = logging.getLogger(__name__) def get_argparser(): parser = argparse.ArgumentParser(description="ARTIQ master") + parser.add_argument("--version", action="version", + version="ARTIQ v{}".format(artiq_version), + help="print the ARTIQ version number") common_args.simple_network_args(parser, [ ("notify", "notifications", 3250), diff --git a/artiq/frontend/artiq_run.py b/artiq/frontend/artiq_run.py index c235387c9..4e6f2b7a3 100755 --- a/artiq/frontend/artiq_run.py +++ b/artiq/frontend/artiq_run.py @@ -14,6 +14,7 @@ from llvmlite_artiq import binding as llvm from sipyco import common_args +from artiq import __version__ as artiq_version from artiq.language.environment import EnvExperiment, ProcessArgumentManager from artiq.language.types import TBool from artiq.master.databases import DeviceDB, DatasetDB @@ -127,6 +128,9 @@ class DummyCCB: def get_argparser(with_file=True): parser = argparse.ArgumentParser( description="Local experiment running tool") + parser.add_argument("--version", action="version", + version="ARTIQ v{}".format(artiq_version), + help="print the ARTIQ version number") common_args.verbosity_args(parser) parser.add_argument("--device-db", default="device_db.py", diff --git a/artiq/frontend/artiq_session.py b/artiq/frontend/artiq_session.py index b04a83008..be9fa4ae1 100755 --- a/artiq/frontend/artiq_session.py +++ b/artiq/frontend/artiq_session.py @@ -3,7 +3,7 @@ import argparse import sys import subprocess - +from artiq import __version__ as artiq_version def get_argparser(): @@ -11,6 +11,9 @@ def get_argparser(): description="ARTIQ session manager. " "Automatically runs the master, dashboard and " "local controller manager on the current machine.") + parser.add_argument("--version", action="version", + version="ARTIQ v{}".format(artiq_version), + help="print the ARTIQ version number") parser.add_argument("-m", action="append", default=[], help="add argument to the master command line") parser.add_argument("-d", action="append", default=[],