Пример #1
0
    def addVisibility(self,
                      body,
                      es_type,
                      scroll_time='1m',
                      visibility=Visibility(formalVisibility='U')):
        
        visibility_field = 'ezbake_visibility'
        visibility = serialize_to_base64(visibility)

        res = self._es.search(body=body,
                              index=self._es_index,
                              doc_type=es_type,
                              search_type='scan',
                              scroll='1m')

        while True:
            scroll_id = res['_scroll_id']
            res = self._es.scroll(scroll_id=scroll_id, scroll=scroll_time)
            hits = res['hits']['hits']
            if not res or len(hits) == 0: break
            for hit in hits:
                _id = hit['_id']
                body = {"doc": {visibility_field: visibility}}

                self._es.update(index=self._es_index,
                                doc_type=es_type,
                                id=_id,
                                body=body)
    def test_serialize_deserialize(self):
        original_object = ttypes.Test(15, "testobject")

        # test serialization, not sure how to make sure it's base64
        base64_serialized = utils.serialize_to_base64(original_object)
        nt.assert_true(isinstance(base64_serialized, str))

        # test deserialization, make sure we get back the type we're expecting
        deserialized_object = utils.deserialize_from_base64(ttypes.Test, base64_serialized)
        nt.assert_true(isinstance(deserialized_object, ttypes.Test))

        # make sure the deserialized object equals the original
        nt.assert_equal(original_object, deserialized_object)
Пример #3
0
 def _b64vis(self, visibility):
     return serialize_to_base64(visibility)