forked from M-Labs/artiq
1
0
Fork 0

controllers/thorlabs_tcube: accept any case for -P. Closes #150

This commit is contained in:
Sebastien Bourdeauducq 2015-10-21 09:17:39 +08:00
parent eb546bf4a0
commit ec02bea054
1 changed files with 7 additions and 6 deletions

View File

@ -12,7 +12,7 @@ def get_argparser():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("-P", "--product", required=True, parser.add_argument("-P", "--product", required=True,
help="type of the Thorlabs T-Cube device to control", help="type of the Thorlabs T-Cube device to control",
choices=["TDC001", "TPZ001"]) choices=["tdc001", "tpz001"])
parser.add_argument("-d", "--device", default=None, parser.add_argument("-d", "--device", default=None,
help="serial device. See documentation for how to " help="serial device. See documentation for how to "
"specify a USB Serial Number.") "specify a USB Serial Number.")
@ -33,19 +33,20 @@ def main():
"argument. Use --help for more information.") "argument. Use --help for more information.")
sys.exit(1) sys.exit(1)
product = args.product.lower()
if args.simulation: if args.simulation:
if args.product == "TDC001": if product == "tdc001":
dev = TdcSim() dev = TdcSim()
elif args.product == "TPZ001": elif product == "tpz001":
dev = TpzSim() dev = TpzSim()
else: else:
if args.product == "TDC001": if product == "tdc001":
dev = Tdc(args.device) dev = Tdc(args.device)
elif args.product == "TPZ001": elif product == "tpz001":
dev = Tpz(args.device) dev = Tpz(args.device)
try: try:
simple_server_loop({args.product.lower(): dev}, args.bind, args.port) simple_server_loop({product: dev}, args.bind, args.port)
finally: finally:
dev.close() dev.close()