mirror of https://github.com/m-labs/artiq.git
browser: add update method to dataset controller
This commit is contained in:
parent
bf46ce4a92
commit
7ad32d903a
|
@ -28,21 +28,34 @@ class DatasetCtl:
|
||||||
self.master_host = master_host
|
self.master_host = master_host
|
||||||
self.master_port = master_port
|
self.master_port = master_port
|
||||||
|
|
||||||
async def set(self, key, value, persist=None):
|
async def _execute_rpc(self, op_name, key_or_mod, value=None, persist=None):
|
||||||
logger.info("Uploading dataset '%s' to master...", key)
|
logger.info("Starting %s operation on %s", op_name, key_or_mod)
|
||||||
try:
|
try:
|
||||||
remote = RPCClient()
|
remote = RPCClient()
|
||||||
await remote.connect_rpc(self.master_host, self.master_port,
|
await remote.connect_rpc(self.master_host, self.master_port,
|
||||||
"master_dataset_db")
|
"master_dataset_db")
|
||||||
try:
|
try:
|
||||||
await remote.set(key, value, persist)
|
if op_name == "set":
|
||||||
|
await remote.set(key_or_mod, value, persist)
|
||||||
|
elif op_name == "update":
|
||||||
|
await remote.update(key_or_mod)
|
||||||
|
else:
|
||||||
|
logger.error("Invalid operation: %s", op_name)
|
||||||
|
return
|
||||||
finally:
|
finally:
|
||||||
remote.close_rpc()
|
remote.close_rpc()
|
||||||
except:
|
except:
|
||||||
logger.error("Failed uploading dataset '%s'",
|
logger.error("Failed %s operation on %s", op_name,
|
||||||
key, exc_info=True)
|
key_or_mod, exc_info=True)
|
||||||
else:
|
else:
|
||||||
logger.info("Finished uploading dataset '%s'", key)
|
logger.info("Finished %s operation on %s", op_name,
|
||||||
|
key_or_mod)
|
||||||
|
|
||||||
|
async def set(self, key, value, persist=None):
|
||||||
|
await self._execute_rpc("set", key, value, persist)
|
||||||
|
|
||||||
|
async def update(self, mod):
|
||||||
|
await self._execute_rpc("update", mod)
|
||||||
|
|
||||||
|
|
||||||
class DatasetsDock(QtWidgets.QDockWidget):
|
class DatasetsDock(QtWidgets.QDockWidget):
|
||||||
|
|
Loading…
Reference in New Issue