artiq_coremgmt: remove unnecessary DeviceManager

This commit is contained in:
Sebastien Bourdeauducq 2018-08-18 10:46:08 +08:00
parent 167e97efd2
commit fc09144baa
1 changed files with 50 additions and 55 deletions

View File

@ -5,7 +5,6 @@ import struct
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_kernel import CommKernel
from artiq.coredevice.comm_mgmt import CommMgmt
from artiq.coredevice.profiler import CallgrindWriter
@ -134,67 +133,63 @@ def main():
args = get_argparser().parse_args()
init_logger(args)
device_mgr = DeviceManager(DeviceDB(args.device_db))
try:
core_addr = DeviceDB(args.device_db).get("core")["arguments"]["host"]
mgmt = CommMgmt(core_addr)
core_addr = DeviceDB(args.device_db).get("core")["arguments"]["host"]
mgmt = CommMgmt(core_addr)
if args.tool == "log":
if args.action == "set_level":
mgmt.set_log_level(args.level)
if args.action == "set_uart_level":
mgmt.set_uart_log_level(args.level)
if args.action == "clear":
mgmt.clear_log()
if args.action == None:
print(mgmt.get_log(), end="")
if args.tool == "log":
if args.action == "set_level":
mgmt.set_log_level(args.level)
if args.action == "set_uart_level":
mgmt.set_uart_log_level(args.level)
if args.action == "clear":
mgmt.clear_log()
if args.action == None:
print(mgmt.get_log(), end="")
if args.tool == "config":
if args.action == "read":
value = mgmt.config_read(args.key)
if not value:
print("Key {} does not exist".format(args.key))
else:
print(value)
if args.action == "write":
for key, value in args.string:
mgmt.config_write(key, value.encode("utf-8"))
for key, filename in args.file:
with open(filename, "rb") as fi:
mgmt.config_write(key, fi.read())
if args.action == "remove":
for key in args.key:
mgmt.config_remove(key)
if args.action == "erase":
mgmt.config_erase()
if args.tool == "config":
if args.action == "read":
value = mgmt.config_read(args.key)
if not value:
print("Key {} does not exist".format(args.key))
else:
print(value)
if args.action == "write":
for key, value in args.string:
mgmt.config_write(key, value.encode("utf-8"))
for key, filename in args.file:
with open(filename, "rb") as fi:
mgmt.config_write(key, fi.read())
if args.action == "remove":
for key in args.key:
mgmt.config_remove(key)
if args.action == "erase":
mgmt.config_erase()
if args.tool == "reboot":
mgmt.reboot()
if args.tool == "reboot":
mgmt.reboot()
if args.tool == "hotswap":
mgmt.hotswap(args.image.read())
if args.tool == "hotswap":
mgmt.hotswap(args.image.read())
if args.tool == "profile":
if args.action == "start":
mgmt.start_profiler(args.interval, args.hits_size, args.edges_size)
elif args.action == "stop":
mgmt.stop_profiler()
elif args.action == "save":
hits, edges = mgmt.get_profile()
writer = CallgrindWriter(args.output, args.firmware, "or1k-linux",
args.compression, args.demangle)
writer.header()
for addr, count in hits.items():
writer.hit(addr, count)
for (caller, callee), count in edges.items():
writer.edge(caller, callee, count)
if args.tool == "profile":
if args.action == "start":
mgmt.start_profiler(args.interval, args.hits_size, args.edges_size)
elif args.action == "stop":
mgmt.stop_profiler()
elif args.action == "save":
hits, edges = mgmt.get_profile()
writer = CallgrindWriter(args.output, args.firmware, "or1k-linux",
args.compression, args.demangle)
writer.header()
for addr, count in hits.items():
writer.hit(addr, count)
for (caller, callee), count in edges.items():
writer.edge(caller, callee, count)
if args.tool == "debug":
if args.action == "allocator":
mgmt.debug_allocator()
if args.tool == "debug":
if args.action == "allocator":
mgmt.debug_allocator()
finally:
device_mgr.close_devices()
if __name__ == "__main__":
main()