|
2 | 2 |
|
3 | 3 | import argparse
|
4 | 4 |
|
5 |
| -from artiq.master.worker_db import create_device |
| 5 | +from artiq.master.worker_db import DeviceManager |
6 | 6 | from artiq.protocols.file_db import FlatFileDB
|
7 | 7 |
|
8 | 8 |
|
@@ -44,26 +44,29 @@ def get_argparser():
|
44 | 44 |
|
45 | 45 | def main():
|
46 | 46 | args = get_argparser().parse_args()
|
47 |
| - ddb = FlatFileDB(args.ddb) |
48 |
| - comm = create_device(ddb.request("comm"), None) |
| 47 | + dmgr = DeviceManager(FlatFileDB(args.ddb)) |
| 48 | + try: |
| 49 | + comm = dmgr.get("comm") |
49 | 50 |
|
50 |
| - if args.action == "read": |
51 |
| - value = comm.flash_storage_read(args.key) |
52 |
| - if not value: |
53 |
| - print("Key {} does not exist".format(args.key)) |
54 |
| - else: |
55 |
| - print(value) |
56 |
| - elif args.action == "erase": |
57 |
| - comm.flash_storage_erase() |
58 |
| - elif args.action == "delete": |
59 |
| - for key in args.key: |
60 |
| - comm.flash_storage_remove(key) |
61 |
| - elif args.action == "write": |
62 |
| - for key, value in args.string: |
63 |
| - comm.flash_storage_write(key, value) |
64 |
| - for key, filename in args.file: |
65 |
| - with open(filename, "rb") as fi: |
66 |
| - comm.flash_storage_write(key, fi.read()) |
| 51 | + if args.action == "read": |
| 52 | + value = comm.flash_storage_read(args.key) |
| 53 | + if not value: |
| 54 | + print("Key {} does not exist".format(args.key)) |
| 55 | + else: |
| 56 | + print(value) |
| 57 | + elif args.action == "erase": |
| 58 | + comm.flash_storage_erase() |
| 59 | + elif args.action == "delete": |
| 60 | + for key in args.key: |
| 61 | + comm.flash_storage_remove(key) |
| 62 | + elif args.action == "write": |
| 63 | + for key, value in args.string: |
| 64 | + comm.flash_storage_write(key, value) |
| 65 | + for key, filename in args.file: |
| 66 | + with open(filename, "rb") as fi: |
| 67 | + comm.flash_storage_write(key, fi.read()) |
| 68 | + finally: |
| 69 | + dmgr.close_devices() |
67 | 70 |
|
68 | 71 | if __name__ == "__main__":
|
69 | 72 | main()
|
0 commit comments