Esempio n. 1
0
    def get_namespaces(self):
        # Skip auth-ing to db in test operations
        if not self.argv:
            return ['4952435991248896_1']

        query_pb = query_pb2.Query()
        helper.set_kind(query_pb, "__namespace__")
        client = apache_helper.get_datastore(PROJECT)
        namespace_entities = apache_helper.fetch_entities(
            PROJECT, '', query_pb, client)

        namespaces = []
        for n in namespace_entities:
            # Get namespace name or id
            key_path = n.key.path[-1]
            if key_path.HasField('id'):
                name_or_id = key_path.id
            else:
                name_or_id = key_path.name

            # Avoid duplicates and test namespaces
            if len(str(name_or_id)) > 1 and name_or_id not in namespaces:
                namespaces.append(name_or_id)

        return namespaces
Esempio n. 2
0
 def process(self, query, *args, **kwargs):
     # Returns an iterator of entities that reads in batches.
     entities = helper.fetch_entities(self._project,
                                      self._datastore_namespace, query,
                                      self._datastore)
     return entities
Esempio n. 3
0
 def process(self, query, *args, **kwargs):
   # Returns an iterator of entities that reads in batches.
   entities = helper.fetch_entities(self._project, self._datastore_namespace,
                                    query, self._datastore)
   return entities