def RecreatePathing(self, pathing=None):
   if not pathing:
     pathing = config.CONFIG.Get("Datastore.pathing")
   try:
     self.path_regexes = [re.compile(path) for path in pathing]
     self.pathing = pathing
   except re.error:
     raise data_store.Error("Invalid regular expression in Datastore.pathing")
Beispiel #2
0
def CheckResponseStatus(response):
    """Catch error conditions from the response and raise them."""
    # Common case exit early.
    if response.status == rdf_data_store.DataStoreResponse.Status.OK:
        return response

    elif (response.status ==
          rdf_data_store.DataStoreResponse.Status.AUTHORIZATION_DENIED):
        raise access_control.UnauthorizedAccess(response.status_desc,
                                                response.failed_subject)

    elif response.status == rdf_data_store.DataStoreResponse.Status.TIMEOUT_ERROR:
        raise data_store.TimeoutError(response.status_desc)

    elif (response.status ==
          rdf_data_store.DataStoreResponse.Status.DATA_STORE_ERROR):
        raise data_store.Error(response.status_desc)

    raise data_store.Error("Unknown error %s" % response.status_desc)
    def _TimestampToFilter(self, timestamp):
        if timestamp == data_store.DataStore.ALL_TIMESTAMPS:
            return None

        if timestamp is None or timestamp == data_store.DataStore.NEWEST_TIMESTAMP:
            # Latest value only
            return row_filters.CellsColumnLimitFilter(1)

        if isinstance(timestamp, tuple):
            return row_filters.TimestampRangeFilter(
                self._TimestampRangeFromTuple(timestamp))

        raise data_store.Error("Invalid timestamp specification: %s." %
                               timestamp)