coreconfig: use new database API (closes #75)

This commit is contained in:
Sebastien Bourdeauducq 2015-07-17 10:49:55 +02:00
parent 9649e1837a
commit 39c6bc940c
2 changed files with 25 additions and 22 deletions

View File

@ -2,7 +2,7 @@
import argparse import argparse
from artiq.master.worker_db import create_device from artiq.master.worker_db import DeviceManager
from artiq.protocols.file_db import FlatFileDB from artiq.protocols.file_db import FlatFileDB
@ -44,8 +44,9 @@ def get_argparser():
def main(): def main():
args = get_argparser().parse_args() args = get_argparser().parse_args()
ddb = FlatFileDB(args.ddb) dmgr = DeviceManager(FlatFileDB(args.ddb))
comm = create_device(ddb.request("comm"), None) try:
comm = dmgr.get("comm")
if args.action == "read": if args.action == "read":
value = comm.flash_storage_read(args.key) value = comm.flash_storage_read(args.key)
@ -64,6 +65,8 @@ def main():
for key, filename in args.file: for key, filename in args.file:
with open(filename, "rb") as fi: with open(filename, "rb") as fi:
comm.flash_storage_write(key, fi.read()) comm.flash_storage_write(key, fi.read())
finally:
dmgr.close_devices()
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -103,7 +103,7 @@ class ResultDB:
result_dict_to_hdf5(f, self.nrt) result_dict_to_hdf5(f, self.nrt)
def create_device(desc, dmgr): def _create_device(desc, dmgr):
ty = desc["type"] ty = desc["type"]
if ty == "local": if ty == "local":
module = importlib.import_module(desc["module"]) module = importlib.import_module(desc["module"])
@ -139,7 +139,7 @@ class DeviceManager:
while isinstance(desc, str): while isinstance(desc, str):
# alias # alias
desc = self.ddb.get(desc) desc = self.ddb.get(desc)
dev = create_device(desc, self) dev = _create_device(desc, self)
self.active_devices[name] = dev self.active_devices[name] = dev
return dev return dev