Python google.appengine.runtime.apiproxy_errors.FeatureNotEnabledError() Examples

The following are code examples for showing how to use google.appengine.runtime.apiproxy_errors.FeatureNotEnabledError(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: luci-py   Author: luci   File: handlers.py    Apache License 2.0 6 votes vote down vote up
def _has_old_request_ended(self, shard_state):
    """Whether previous slice retry has ended according to Logs API.

    Args:
      shard_state: shard state.

    Returns:
      True if the request of previous slice retry has ended. False if it has
    not or unknown.
    """
    assert shard_state.slice_start_time is not None
    assert shard_state.slice_request_id is not None
    request_ids = [shard_state.slice_request_id]
    logs = None
    try:
      logs = list(logservice.fetch(request_ids=request_ids))
    except (apiproxy_errors.FeatureNotEnabledError,
        apiproxy_errors.CapabilityDisabledError) as e:
      # Managed VMs do not have access to the logservice API
      # See https://groups.google.com/forum/#!topic/app-engine-managed-vms/r8i65uiFW0w
      logging.warning("Ignoring exception: %s", e)

    if not logs or not logs[0].finished:
      return False
    return True 
Example 2
Project: luci-py   Author: luci   File: handlers.py    Apache License 2.0 6 votes vote down vote up
def _has_old_request_ended(self, shard_state):
    """Whether previous slice retry has ended according to Logs API.

    Args:
      shard_state: shard state.

    Returns:
      True if the request of previous slice retry has ended. False if it has
    not or unknown.
    """
    assert shard_state.slice_start_time is not None
    assert shard_state.slice_request_id is not None
    request_ids = [shard_state.slice_request_id]
    logs = None
    try:
      logs = list(logservice.fetch(request_ids=request_ids))
    except (apiproxy_errors.FeatureNotEnabledError,
        apiproxy_errors.CapabilityDisabledError) as e:
      # Managed VMs do not have access to the logservice API
      # See https://groups.google.com/forum/#!topic/app-engine-managed-vms/r8i65uiFW0w
      logging.warning("Ignoring exception: %s", e)

    if not logs or not logs[0].finished:
      return False
    return True 
Example 3
Project: python-compat-runtime   Author: GoogleCloudPlatform   File: apiproxy.py    Apache License 2.0 4 votes vote down vote up
def _MakeCallDone(self):
    self._state = RPC.FINISHING
    self.cpu_usage_mcycles = self._result_dict['cpu_usage_mcycles']
    if self._result_dict['error'] == APPLICATION_ERROR:
      appl_err = self._result_dict['application_error']
      if appl_err == MEMCACHE_UNAVAILABLE and self.package == 'memcache':


        self._exception = apiproxy_errors.CapabilityDisabledError(
            'The memcache service is temporarily unavailable. %s'
            % self._result_dict['error_detail'])
      else:

        self._exception = apiproxy_errors.ApplicationError(
            appl_err,
            self._result_dict['error_detail'])
    elif self._result_dict['error'] == CAPABILITY_DISABLED:

      if self._result_dict['error_detail']:
        self._exception = apiproxy_errors.CapabilityDisabledError(
            self._result_dict['error_detail'])
      else:
        self._exception = apiproxy_errors.CapabilityDisabledError(
            "The API call %s.%s() is temporarily unavailable." % (
            self.package, self.call))
    elif self._result_dict['error'] == FEATURE_DISABLED:
      self._exception = apiproxy_errors.FeatureNotEnabledError(
            self._result_dict['error_detail'])
    elif self._result_dict['error'] == OVER_QUOTA:
      if self._result_dict['error_detail']:

        self._exception = apiproxy_errors.OverQuotaError(
            ('The API call %s.%s() required more quota than is available. %s' %
             (self.package, self.call, self._result_dict['error_detail'])))
      else:

        exception_entry = _ExceptionsMap[self._result_dict['error']]
        self._exception = exception_entry[0](
            exception_entry[1] % (self.package, self.call))
    elif self._result_dict['error'] in _ExceptionsMap:
      exception_entry = _ExceptionsMap[self._result_dict['error']]
      self._exception = exception_entry[0](
          exception_entry[1] % (self.package, self.call))
    else:
      try:
        self.response.ParseFromString(self._result_dict['result_string'])
      except Exception, e:
        self._exception = e