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,26 +44,29 @@ 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)
if not value:
print("Key {} does not exist".format(args.key))
else:
print(value)
elif args.action == "erase":
comm.flash_storage_erase()
elif args.action == "delete":
for key in args.key:
comm.flash_storage_remove(key)
elif args.action == "write":
for key, value in args.string:
comm.flash_storage_write(key, value)
for key, filename in args.file:
with open(filename, "rb") as fi:
comm.flash_storage_write(key, fi.read())
if args.action == "read":
value = comm.flash_storage_read(args.key)
if not value:
print("Key {} does not exist".format(args.key))
else:
print(value)
elif args.action == "erase":
comm.flash_storage_erase()
elif args.action == "delete":
for key in args.key:
comm.flash_storage_remove(key)
elif args.action == "write":
for key, value in args.string:
comm.flash_storage_write(key, value)
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