forked from M-Labs/artiq
1
0
Fork 0

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

View File

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