def load(self, snapshot_id): """Retrieve snapshot data :param snapshot_id int: ID of snapshot :rtype list: :return: list of Parameter entries""" self.logger.debug('load snapshot %d', snapshot_id) path = self._build_snapshot_path(snapshot_id) if not os.path.exists(path): raise KeyError('snapshot {:d} not found'.format(snapshot_id)) with open(path, 'r') as inf: snapshot_data = ParameterCodec(as_set=True).decode(inf.read()) return snapshot_data
def _save_snapshot(cls, path, parameters): with open(path, 'w') as outf: outf.write(ParameterCodec(as_set=True).encode(parameters))
def setUp(self): self.codec = ParameterCodec(as_set=True)
def test_encode_no_set(self): p = Parameter('foo', 'bar', str) # this should produce a valid json codec = ParameterCodec() self.assertRaises(NotImplementedError, codec.encode, p)
def _publish_param(self, param): as_json = ParameterCodec(as_set=True).encode(param) _log.debug('publish to %s: %s', self.topic, as_json) self.client.publish(self.topic, as_json)