Ejemplo n.º 1
0
def get_build_data():
    """ Return a dict of build data, messages, warnings, errors.

    """
    data = dict()
    data['build_messages'] = list()
    data['build_warnings'] = list()
    data['build_error'] = ''

    build_data_path = os.path.join(jenkinstools.get_workspace(),
                                   'build_data.txt')
    if os.path.isfile(build_data_path):
        with open(build_data_path, 'r') as f:
            while True:
                try:
                    # Read a single item from the file, and get response type.
                    var = cPickle.load(f)
                    response_type = var.keys()[0]
                    # If it is a message, add to list of messages.
                    if response_type == 'build_message':
                        data['build_messages'].append(var.get('build_message'))
                    # If it is a warning, add to list of warnings.
                    elif response_type == 'build_warning':
                        data['build_warnings'].append(var.get('build_warning'))
                    # Can only have one error (fatal).
                    elif response_type == 'build_error':
                        data['build_error'] = var.get('build_error')
                    # General build data. Update data dict.
                    else:
                        data.update(var)
                except (EOFError, ImportError, IndexError):
                    break
    return data
Ejemplo n.º 2
0
def get_build_data():
    """ Return a dict of build data, messages, warnings, errors.

    """
    data = dict()
    data['build_messages'] = list()
    data['build_warnings'] = list()
    data['build_error'] = ''

    build_data_path = os.path.join(jenkinstools.get_workspace(), 'build_data.txt')
    if os.path.isfile(build_data_path):
        with open(build_data_path, 'r') as f:
            while True:
                try:
                    # Read a single item from the file, and get response type.
                    var = cPickle.load(f)
                    response_type = var.keys()[0]
                    # If it is a message, add to list of messages.
                    if response_type == 'build_message':
                        data['build_messages'].append(var.get('build_message'))
                    # If it is a warning, add to list of warnings.
                    elif response_type == 'build_warning':
                        data['build_warnings'].append(var.get('build_warning'))
                    # Can only have one error (fatal). 
                    elif response_type == 'build_error':
                        data['build_error'] = var.get('build_error')
                    # General build data. Update data dict.
                    else:
                        data.update(var)
                except (EOFError, ImportError, IndexError):
                    break
    return data
Ejemplo n.º 3
0
def write_build_data(response_type, data):
    """ Write pickled data to workspace for jenkins job_name.

    response_type: The type of response data (generally a job name). May not
               be the same as the initiating jenkins job (multiple responses).
    data: Info to be written to file for later retrieval in Atlas postback.

    """
    build_data_path = os.path.join(jenkinstools.get_workspace(), 'build_data.txt')

    with open(build_data_path, 'a') as f:
        cPickle.dump({response_type:data}, f)
Ejemplo n.º 4
0
def write_build_data(response_type, data):
    """ Write pickled data to workspace for jenkins job_name.

    response_type: The type of response data (generally a job name). May not
               be the same as the initiating jenkins job (multiple responses).
    data: Info to be written to file for later retrieval in Atlas postback.

    """
    build_data_path = os.path.join(jenkinstools.get_workspace(), 'build_data.txt')

    with open(build_data_path, 'a') as f:
        cPickle.dump({response_type:data}, f)