mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-25 03:08:27 +08:00
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():
|
||||
parser = argparse.ArgumentParser(description="ARTIQ master")
|
||||
parser.add_argument(
|
||||
group = parser.add_argument_group("network")
|
||||
group.add_argument(
|
||||
"--bind", default="::1",
|
||||
help="hostname or IP address to bind to")
|
||||
parser.add_argument(
|
||||
group.add_argument(
|
||||
"--port-notify", default=3250, type=int,
|
||||
help="TCP port to listen to for notifications")
|
||||
parser.add_argument(
|
||||
group.add_argument(
|
||||
"--port-control", default=3251, type=int,
|
||||
help="TCP port to listen to for control")
|
||||
verbosity_args(parser)
|
||||
|
@ -4,17 +4,14 @@ import argparse
|
||||
|
||||
from artiq.devices.lda.driver import Lda, Ldasim
|
||||
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():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-d', '--device', default="LDA-102",
|
||||
choices=["LDA-102", "LDA-602", "sim"])
|
||||
parser.add_argument('--bind', default="::1",
|
||||
help="hostname or IP address to bind to")
|
||||
parser.add_argument('-p', '--port', default=3253, type=int,
|
||||
help="TCP port to listen to")
|
||||
simple_network_args(parser, 3253)
|
||||
parser.add_argument('-s', '--serial', default=None,
|
||||
help="USB serial number of the device")
|
||||
verbosity_args(parser)
|
||||
|
@ -4,15 +4,12 @@ import argparse
|
||||
|
||||
from artiq.devices.pdq2.driver import Pdq2
|
||||
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():
|
||||
parser = argparse.ArgumentParser(description="PDQ2 controller")
|
||||
parser.add_argument("--bind", default="::1",
|
||||
help="hostname or IP address to bind to")
|
||||
parser.add_argument("-p", "--port", default=3252, type=int,
|
||||
help="TCP port to listen to")
|
||||
simple_network_args(parser, 3252)
|
||||
parser.add_argument(
|
||||
"-s", "--serial", default=None,
|
||||
help="device (FT245R) serial string [first]")
|
||||
@ -25,7 +22,6 @@ def get_argparser():
|
||||
|
||||
def main():
|
||||
args = get_argparser().parse_args()
|
||||
|
||||
init_logger(args)
|
||||
|
||||
dev = Pdq2(serial=args.serial)
|
||||
|
@ -38,5 +38,13 @@ def verbosity_args(parser):
|
||||
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):
|
||||
logging.basicConfig(level=logging.WARNING + args.quiet*10 - args.verbose*10)
|
||||
|
Loading…
Reference in New Issue
Block a user