コード例 #1
0
def get_versions_async(module=None):
    """Returns a UserRPC whose result contains list of versions for a module.

  DEPRECATED. Please use get_versions instead.

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

  Returns:
    Returns a UserRPC whose result contains the list of strings containing
    the names of versions associated with the specified module.
  """
    logging.warning('The get_versions_async function is deprecated. Please '
                    'use get_versions instead.')

    def _ResultHook(rpc):
        mapped_errors = [
            modules_service_pb.ModulesServiceError.INVALID_MODULE,
            modules_service_pb.ModulesServiceError.TRANSIENT_ERROR
        ]
        _CheckAsyncResult(rpc, mapped_errors, {})

        return list(rpc.response.version_list())

    request = modules_service_pb.GetVersionsRequest()
    if module:
        request.set_module(module)
    response = modules_service_pb.GetVersionsResponse()
    return _MakeAsyncCall('GetVersions', request, response, _ResultHook)
コード例 #2
0
ファイル: modules.py プロジェクト: startup-one/cogofly
def get_versions(module=None):
    """Returns a list of versions for a given module.

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

  Returns:
    List of strings containing the names of versions associated with the module.
    The current version will also be included in this list.

  Raises:
    InvalidModuleError if the given module isn't valid, TransientError if there
    is an issue fetching the information.
  """
    def _ResultHook(rpc):
        mapped_errors = [
            modules_service_pb.ModulesServiceError.INVALID_MODULE,
            modules_service_pb.ModulesServiceError.TRANSIENT_ERROR
        ]
        _CheckAsyncResult(rpc, mapped_errors, {})

        return list(rpc.response.version_list())

    request = modules_service_pb.GetVersionsRequest()
    if module:
        request.set_module(module)
    response = modules_service_pb.GetVersionsResponse()
    return _MakeAsyncCall('GetVersions', request, response,
                          _ResultHook).get_result()
コード例 #3
0
ファイル: modules.py プロジェクト: rowhit/appscale
def get_versions(module=None):
    """Returns a list of versions for a given module.

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

  Returns:
    List of strings containing the names of versions associated with the module.
    The current version will also be included in this list.

  Raises:
    InvalidModuleError if the given module isn't valid, TransientError if there
    is an issue fetching the information.
  """
    req = modules_service_pb.GetVersionsRequest()
    if module:
        req.set_module(module)
    resp = modules_service_pb.GetVersionsResponse()
    try:
        apiproxy_stub_map.MakeSyncCall('modules', 'GetVersions', req, resp)
    except apiproxy_errors.ApplicationError, e:
        if (e.application_error ==
                modules_service_pb.ModulesServiceError.INVALID_MODULE):
            raise InvalidModuleError()
        elif (e.application_error ==
              modules_service_pb.ModulesServiceError.TRANSIENT_ERROR):
            raise TransientError()
        else:
            raise Error()