예제 #1
0
    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
예제 #2
0
 def _save_snapshot(cls, path, parameters):
     with open(path, 'w') as outf:
         outf.write(ParameterCodec(as_set=True).encode(parameters))
예제 #3
0
 def setUp(self):
     self.codec = ParameterCodec(as_set=True)
예제 #4
0
    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)
예제 #5
0
 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)