예제 #1
0
파일: main.py 프로젝트: dockerq/dcos-cli
def _task(task, all_, completed, json_):
    """List DCOS tasks

    :param task: task id filter
    :type task: str
    :param all_: If True, include all tasks
    :type all_: bool
    :param completed: If True, include only completed tasks
    :type completed: bool
    :param json_: If True, output json.  Otherwise, output a human
                  readable table.
    :type json_: bool
    :returns: process return code
    """

    tasks = sorted(mesos.get_master().tasks(
                   fltr=task, completed=completed, all_=all_),
                   key=lambda t: t['name'])

    if json_:
        emitter.publish([t.dict() for t in tasks])
    else:
        table = tables.task_table(tasks)
        output = six.text_type(table)
        if output:
            emitter.publish(output)

    return 0
예제 #2
0
파일: main.py 프로젝트: sttts/dcos-cli
def _task(fltr, completed, json_):
    """List DCOS tasks

    :param fltr: task id filter
    :type fltr: str
    :param completed: If True, include completed tasks
    :type completed: bool
    :param json_: If True, output json.  Otherwise, output a human
                  readable table.
    :type json_: bool
    :returns: process return code

    """

    if fltr is None:
        fltr = ""

    tasks = sorted(mesos.get_master().tasks(completed=completed, fltr=fltr),
                   key=lambda task: task['name'])

    if json_:
        emitter.publish([task.dict() for task in tasks])
    else:
        table = tables.task_table(tasks)
        output = str(table)
        if output:
            emitter.publish(output)

    return 0
예제 #3
0
파일: main.py 프로젝트: sschneid/dcos-cli
def _task(task, all_, completed, json_):
    """List DCOS tasks

    :param task: task id filter
    :type task: str
    :param all_: If True, include all tasks
    :type all_: bool
    :param completed: If True, include only completed tasks
    :type completed: bool
    :param json_: If True, output json.  Otherwise, output a human
                  readable table.
    :type json_: bool
    :returns: process return code
    """

    tasks = sorted(mesos.get_master().tasks(
        fltr=task, completed=completed, all_=all_),
        key=lambda t: t['name'])

    if json_:
        emitter.publish([t.dict() for t in tasks])
    else:
        table = tables.task_table(tasks)
        output = six.text_type(table)
        if output:
            emitter.publish(output)

    return 0
예제 #4
0
def _task(fltr, completed, json_):
    """List DCOS tasks

    :param fltr: task id filter
    :type fltr: str
    :param completed: If True, include completed tasks
    :type completed: bool
    :param json_: If True, output json.  Otherwise, output a human
                  readable table.
    :type json_: bool
    :returns: process return code
    """

    if fltr is None:
        fltr = ""

    tasks = sorted(mesos.get_master().tasks(completed=completed, fltr=fltr),
                   key=lambda task: task['name'])

    if json_:
        emitter.publish([task.dict() for task in tasks])
    else:
        table = tables.task_table(tasks)
        output = str(table)
        if output:
            emitter.publish(output)

    return 0
예제 #5
0
def _task(task, all_, completed, json_):
    """List DCOS tasks

    :param task: task id filter
    :type task: str
    :param all_: If True, include all tasks
    :type all_: bool
    :param completed: If True, include only completed tasks
    :type completed: bool
    :param json_: If True, output json.  Otherwise, output a human
                  readable table.
    :type json_: bool
    :returns: process return code
    """

    tasks = sorted(mesos.get_master().tasks(fltr=task,
                                            completed=completed,
                                            all_=all_),
                   key=lambda t: t['name'])

    if json_:
        emitter.publish([t.dict() for t in tasks])
        return 0

    if len(tasks) == 0 and task is not None:
        raise DCOSException(
            'Cannot find a task with ID containing "{}"'.format(task))
    else:
        table = tables.task_table(tasks)
        output = six.text_type(table)
        if output:
            emitter.publish(output)

    return 0