worker_db: support read-only mode

This commit is contained in:
Sebastien Bourdeauducq 2015-04-07 15:40:57 +08:00
parent fda4ee1a83
commit ca89b6d0ed
2 changed files with 8 additions and 7 deletions

View File

@ -82,7 +82,7 @@ class AutoDB:
raise KeyError("Device '{}' not found".format(k))
object.__setattr__(self, k, dev)
self.build()
if self.dbh is not None:
if self.dbh is not None and self.realtime_results:
self.dbh.add_rt_results(self.realtime_results)
def __getattr__(self, name):

View File

@ -84,13 +84,14 @@ def _create_device(desc, dbh):
class DBHub:
"""Connects device, parameter and result databases to experiment.
Handle device driver creation and destruction.
"""
def __init__(self, ddb, pdb, rdb):
def __init__(self, ddb, pdb, rdb, read_only=False):
self.ddb = ddb
self.active_devices = OrderedDict()
self.get_parameter = pdb.request
if not read_only:
self.set_parameter = pdb.set
self.add_rt_results = rdb.add_rt_results
self.get_result = rdb.request