コード例 #1
0
def _history(job_id, json_flag=False, show_failures=False):
    """
    :returns: process return code
    :rtype: int
    """

    client = metronome.create_client()
    json_history = client.get_job(job_id, EMBEDS_FOR_JOB_HISTORY)

    if 'history' not in json_history:
        return 0

    if json_flag:
        emitter.publish(json_history)
    else:
        emitter.publish(_get_history_message(json_history, job_id))
        table = tables.job_history_table(
            json_history['history']['successfulFinishedRuns'])
        output = six.text_type(table)
        if output:
            emitter.publish(output)

        if show_failures:
            emitter.publish(_get_history_message(json_history, job_id, False))
            table = tables.job_history_table(
                json_history['history']['failedFinishedRuns'])
            output = six.text_type(table)
            if output:
                emitter.publish(output)

    return 0
コード例 #2
0
ファイル: main.py プロジェクト: sschneid/dcos-cli
def _history(job_id, json_flag=False, show_failures=False):
    """
    :returns: process return code
    :rtype: int
    """

    client = metronome.create_client()
    json_history = client.get_job(job_id, EMBEDS_FOR_JOB_HISTORY)

    if 'history' not in json_history:
        return 0

    if json_flag:
        emitter.publish(json_history)
    else:
        emitter.publish(_get_history_message(json_history, job_id))
        table = tables.job_history_table(
            json_history['history']['successfulFinishedRuns'])
        output = six.text_type(table)
        if output:
            emitter.publish(output)

        if show_failures:
            emitter.publish(_get_history_message(
                            json_history, job_id, False))
            table = tables.job_history_table(
                json_history['history']['failedFinishedRuns'])
            output = six.text_type(table)
            if output:
                emitter.publish(output)

    return 0
コード例 #3
0
def _history(job_id, json_flag=False, failures=False, last=False, quiet=False):
    """
    :returns: process return code
    :rtype: int
    """

    client = metronome.create_client()
    json_history = client.get_job(job_id, EMBEDS_FOR_JOB_HISTORY)

    if 'history' not in json_history:
        return 0

    if failures:
        tasks = json_history['history']['failedFinishedRuns']
    else:
        tasks = json_history['history']['successfulFinishedRuns']

    if quiet:
        if last and len(tasks) > 0:
            emitter.publish(tasks[0].get('id'))
        else:
            for task in tasks:
                emitter.publish(task.get('id'))
    elif json_flag:
        emitter.publish(tasks)
    else:
        emitter.publish(_get_history_message(json_history, job_id, failures))
        table = tables.job_history_table(tasks)
        output = six.text_type(table)
        if output:
            emitter.publish(output)

    return 0
コード例 #4
0
ファイル: main.py プロジェクト: unterstein/dcos-cli
def _history(job_id, json_flag=False, show_failures=False):
    """
    :returns: process return code
    :rtype: int
    """
    response = None
    url = urllib.parse.urljoin(_get_api_url('v1/jobs/'),
                               job_id + METRONOME_EMBEDDED)
    try:
        response = _do_request(url, 'GET')
    except DCOSHTTPException as e:
        raise DCOSException("Job ID does NOT exist.")
    except DCOSException as e:
        raise DCOSException(e)
    else:

        if response.status_code is not 200:
            raise DCOSException("Job ID does NOT exist.")

        json_history = _read_http_response_body(response)

        if 'history' not in json_history:
            return 0

        if json_flag:
            emitter.publish(json_history)
        else:
            emitter.publish(_get_history_message(json_history, job_id))
            table = tables.job_history_table(
                json_history['history']['successfulFinishedRuns'])
            output = six.text_type(table)
            if output:
                emitter.publish(output)

            if show_failures:
                emitter.publish(_get_history_message(
                                json_history, job_id, False))
                table = tables.job_history_table(
                    json_history['history']['failedFinishedRuns'])
                output = six.text_type(table)
                if output:
                    emitter.publish(output)

    return 0
コード例 #5
0
ファイル: main.py プロジェクト: sis-tools/dcos-cli
def _history(job_id, json_flag=False, show_failures=False):
    """
    :returns: process return code
    :rtype: int
    """
    response = None
    url = urllib.parse.urljoin(_get_api_url('v1/jobs/'),
                               job_id + METRONOME_EMBEDDED)
    try:
        response = _do_request(url, 'GET')
    except DCOSHTTPException as e:
        raise DCOSException("Job ID does NOT exist.")
    except DCOSException as e:
        raise DCOSException(e)
    else:

        if response.status_code is not 200:
            raise DCOSException("Job ID does NOT exist.")

        json_history = _read_http_response_body(response)

        if 'history' not in json_history:
            return 0

        if json_flag:
            emitter.publish(json_history)
        else:
            emitter.publish(_get_history_message(json_history, job_id))
            table = tables.job_history_table(
                json_history['history']['successfulFinishedRuns'])
            output = six.text_type(table)
            if output:
                emitter.publish(output)

            if show_failures:
                emitter.publish(_get_history_message(
                                json_history, job_id, False))
                table = tables.job_history_table(
                    json_history['history']['failedFinishedRuns'])
                output = six.text_type(table)
                if output:
                    emitter.publish(output)

    return 0