mirror of https://github.com/m-labs/artiq.git
tools,frontend: common network arguments
This commit is contained in:
parent
7299a2cf02
commit
79a5d8a12a
|
@ -16,13 +16,14 @@ from artiq.tools import verbosity_args, init_logger
|
||||||
|
|
||||||
def get_argparser():
|
def get_argparser():
|
||||||
parser = argparse.ArgumentParser(description="ARTIQ master")
|
parser = argparse.ArgumentParser(description="ARTIQ master")
|
||||||
parser.add_argument(
|
group = parser.add_argument_group("network")
|
||||||
|
group.add_argument(
|
||||||
"--bind", default="::1",
|
"--bind", default="::1",
|
||||||
help="hostname or IP address to bind to")
|
help="hostname or IP address to bind to")
|
||||||
parser.add_argument(
|
group.add_argument(
|
||||||
"--port-notify", default=3250, type=int,
|
"--port-notify", default=3250, type=int,
|
||||||
help="TCP port to listen to for notifications")
|
help="TCP port to listen to for notifications")
|
||||||
parser.add_argument(
|
group.add_argument(
|
||||||
"--port-control", default=3251, type=int,
|
"--port-control", default=3251, type=int,
|
||||||
help="TCP port to listen to for control")
|
help="TCP port to listen to for control")
|
||||||
verbosity_args(parser)
|
verbosity_args(parser)
|
||||||
|
|
|
@ -4,17 +4,14 @@ import argparse
|
||||||
|
|
||||||
from artiq.devices.lda.driver import Lda, Ldasim
|
from artiq.devices.lda.driver import Lda, Ldasim
|
||||||
from artiq.protocols.pc_rpc import simple_server_loop
|
from artiq.protocols.pc_rpc import simple_server_loop
|
||||||
from artiq.tools import verbosity_args, init_logger
|
from artiq.tools import verbosity_args, simple_network_args, init_logger
|
||||||
|
|
||||||
|
|
||||||
def get_argparser():
|
def get_argparser():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('-d', '--device', default="LDA-102",
|
parser.add_argument('-d', '--device', default="LDA-102",
|
||||||
choices=["LDA-102", "LDA-602", "sim"])
|
choices=["LDA-102", "LDA-602", "sim"])
|
||||||
parser.add_argument('--bind', default="::1",
|
simple_network_args(parser, 3253)
|
||||||
help="hostname or IP address to bind to")
|
|
||||||
parser.add_argument('-p', '--port', default=3253, type=int,
|
|
||||||
help="TCP port to listen to")
|
|
||||||
parser.add_argument('-s', '--serial', default=None,
|
parser.add_argument('-s', '--serial', default=None,
|
||||||
help="USB serial number of the device")
|
help="USB serial number of the device")
|
||||||
verbosity_args(parser)
|
verbosity_args(parser)
|
||||||
|
|
|
@ -4,15 +4,12 @@ import argparse
|
||||||
|
|
||||||
from artiq.devices.pdq2.driver import Pdq2
|
from artiq.devices.pdq2.driver import Pdq2
|
||||||
from artiq.protocols.pc_rpc import simple_server_loop
|
from artiq.protocols.pc_rpc import simple_server_loop
|
||||||
from artiq.tools import verbosity_args, init_logger
|
from artiq.tools import verbosity_args, init_logger, simple_network_args
|
||||||
|
|
||||||
|
|
||||||
def get_argparser():
|
def get_argparser():
|
||||||
parser = argparse.ArgumentParser(description="PDQ2 controller")
|
parser = argparse.ArgumentParser(description="PDQ2 controller")
|
||||||
parser.add_argument("--bind", default="::1",
|
simple_network_args(parser, 3252)
|
||||||
help="hostname or IP address to bind to")
|
|
||||||
parser.add_argument("-p", "--port", default=3252, type=int,
|
|
||||||
help="TCP port to listen to")
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-s", "--serial", default=None,
|
"-s", "--serial", default=None,
|
||||||
help="device (FT245R) serial string [first]")
|
help="device (FT245R) serial string [first]")
|
||||||
|
@ -25,7 +22,6 @@ def get_argparser():
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = get_argparser().parse_args()
|
args = get_argparser().parse_args()
|
||||||
|
|
||||||
init_logger(args)
|
init_logger(args)
|
||||||
|
|
||||||
dev = Pdq2(serial=args.serial)
|
dev = Pdq2(serial=args.serial)
|
||||||
|
|
|
@ -38,5 +38,13 @@ def verbosity_args(parser):
|
||||||
help="decrease logging level")
|
help="decrease logging level")
|
||||||
|
|
||||||
|
|
||||||
|
def simple_network_args(parser, default_port):
|
||||||
|
group = parser.add_argument_group("network")
|
||||||
|
group.add_argument("--bind", default="::1",
|
||||||
|
help="hostname or IP address to bind to")
|
||||||
|
group.add_argument("-p", "--port", default=default_port, type=int,
|
||||||
|
help="TCP port to listen to")
|
||||||
|
|
||||||
|
|
||||||
def init_logger(args):
|
def init_logger(args):
|
||||||
logging.basicConfig(level=logging.WARNING + args.quiet*10 - args.verbose*10)
|
logging.basicConfig(level=logging.WARNING + args.quiet*10 - args.verbose*10)
|
||||||
|
|
Loading…
Reference in New Issue