Beispiel #1
0
def get_default_version_async(module=None):
    """Returns a UserRPC whose result contains a module's default version.

  DEPRECATED. Please use get_default_version instead.

  Args:
    module: Module to retrieve the default version for, if None then the current
      module will be used.

  Returns:
    Returns a UserRPC whose result contains a string holding the name of the
    default version of the specified module.
  """
    logging.warning('The get_default_version_async function is deprecated. '
                    'Please use get_default_version instead.')

    def _ResultHook(rpc):
        mapped_errors = [
            modules_service_pb.ModulesServiceError.INVALID_MODULE,
            modules_service_pb.ModulesServiceError.INVALID_VERSION
        ]
        _CheckAsyncResult(rpc, mapped_errors, {})
        return rpc.response.version()

    request = modules_service_pb.GetDefaultVersionRequest()
    if module:
        request.set_module(module)
    response = modules_service_pb.GetDefaultVersionResponse()
    return _MakeAsyncCall('GetDefaultVersion', request, response, _ResultHook)
Beispiel #2
0
def get_default_version(module=None):
    """Returns the name of the default version for the module.

  Args:
    module: Module to retrieve the default version for, if None then the current
      module will be used.

  Returns:
    String containing the name of the default version of the module.

  Raises:
    InvalidModuleError if the given module is not valid, InvalidVersionError if
    no default version could be found.
  """
    def _ResultHook(rpc):
        mapped_errors = [
            modules_service_pb.ModulesServiceError.INVALID_MODULE,
            modules_service_pb.ModulesServiceError.INVALID_VERSION
        ]
        _CheckAsyncResult(rpc, mapped_errors, {})
        return rpc.response.version()

    request = modules_service_pb.GetDefaultVersionRequest()
    if module:
        request.set_module(module)
    response = modules_service_pb.GetDefaultVersionResponse()
    return _MakeAsyncCall('GetDefaultVersion', request, response,
                          _ResultHook).get_result()
Beispiel #3
0
def get_default_version(module=None):
    """Returns the name of the default version for the module.

  Args:
    module: Module to retrieve the default version for, if None then the current
      module will be used.

  Returns:
    String containing the name of the default version of the module.

  Raises:
    InvalidModuleError if the given module is not valid, InvalidVersionError if
    no default version could be found.
  """
    req = modules_service_pb.GetDefaultVersionRequest()
    if module:
        req.set_module(module)
    resp = modules_service_pb.GetDefaultVersionResponse()
    try:
        apiproxy_stub_map.MakeSyncCall('modules', 'GetDefaultVersion', req,
                                       resp)
    except apiproxy_errors.ApplicationError, e:
        if (e.application_error ==
                modules_service_pb.ModulesServiceError.INVALID_MODULE):
            raise InvalidModuleError()
        if (e.application_error ==
                modules_service_pb.ModulesServiceError.INVALID_VERSION):
            raise InvalidVersionError()
        else:
            raise Error()