Пример #1
0
 def __MakeCallDone(self):
     self.__state = RPC.FINISHING
     self.cpu_usage_mcycles = self.__result_dict['cpu_usage_mcycles']
     if self.__result_dict['error'] == APPLICATION_ERROR:
         self.__exception = apiproxy_errors.ApplicationError(
             self.__result_dict['application_error'],
             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'] 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
Пример #2
0
    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