示例#1
0
def _search(json_, query):
    """Search for matching packages.

    :param json_: output json if True
    :type json_: bool
    :param query: The search term
    :type query: str
    :returns: Process status
    :rtype: int
    """
    if not query:
        query = ''

    config = util.get_config()
    results = [index_entry.as_dict()
               for index_entry in package.search(query, config)]

    if any(result['packages'] for result in results) or json_:
        emitting.publish_table(emitter,
                               results,
                               tables.package_search_table,
                               json_)
    else:
        raise DCOSException('No packages found.')
    return 0
示例#2
0
文件: main.py 项目: sttts/dcos-cli
def _search(json_, query):
    """Search for matching packages.

    :param json_: output json if True
    :type json_: bool
    :param query: The search term
    :type query: str
    :returns: Process status
    :rtype: int
    """
    if not query:
        query = ''

    config = util.get_config()
    results = [index_entry.as_dict()
               for index_entry in package.search(query, config)]

    emitting.publish_table(emitter,
                           results,
                           tables.package_search_table,
                           json_)
    return 0
示例#3
0
def _search(json_, query):
    """Search for matching packages.

    :param json_: output json if True
    :type json_: bool
    :param query: The search term
    :type query: str
    :returns: Process status
    :rtype: int
    """
    if not query:
        query = ''

    config = util.get_config()
    results = [
        index_entry.as_dict() for index_entry in package.search(query, config)
    ]

    if any(result['packages'] for result in results) or json_:
        emitting.publish_table(emitter, results, tables.package_search_table,
                               json_)
    else:
        raise DCOSException('No packages found.')
    return 0