artiq_corelog: cleanup

This commit is contained in:
Sebastien Bourdeauducq 2017-05-22 00:06:03 +08:00
parent 8cf0628435
commit c83e15d040
1 changed files with 5 additions and 6 deletions

View File

@ -4,13 +4,12 @@ import argparse
from artiq.tools import verbosity_args, init_logger
from artiq.master.databases import DeviceDB
from artiq.master.worker_db import DeviceManager
from artiq.coredevice.comm_mgmt import CommMgmt
def get_argparser():
parser = argparse.ArgumentParser(description="ARTIQ core device "
"log download tool")
"log tool")
verbosity_args(parser)
parser.add_argument("--device-db", default="device_db.py",
help="device database file (default: '%(default)s')")
@ -37,10 +36,10 @@ def get_argparser():
def main():
args = get_argparser().parse_args()
init_logger(args)
device_mgr = DeviceManager(DeviceDB(args.device_db))
core_addr = DeviceDB(args.device_db).get("comm")["arguments"]["host"]
mgmt = CommMgmt(None, core_addr)
try:
core_addr = device_mgr.get_desc("comm")["arguments"]["host"]
mgmt = CommMgmt(device_mgr, core_addr)
if args.action == "set_level":
mgmt.set_log_level(args.level)
elif args.action == "set_uart_level":
@ -50,7 +49,7 @@ def main():
else:
print(mgmt.get_log(), end="")
finally:
device_mgr.close_devices()
mgmt.close()
if __name__ == "__main__":