def store_text_log_summary_artifact(job, text_log_summary_artifact):
    """
    Store the contents of the text log summary artifact
    """
    step_data = json.loads(
        text_log_summary_artifact['blob'])['step_data']
    result_map = {v: k for (k, v) in TextLogStep.RESULTS}
    with transaction.atomic():
        for step in step_data['steps']:
            name = step['name'][:TextLogStep._meta.get_field('name').max_length]
            # process start/end times if we have them
            # we currently don't support timezones in treeherder, so
            # just ignore that when importing/updating the bug to avoid
            # a ValueError (though by default the text log summaries
            # we produce should have time expressed in UTC anyway)
            time_kwargs = {}
            for tkey in ('started', 'finished'):
                if step.get(tkey):
                    time_kwargs[tkey] = dateutil.parser.parse(
                        step[tkey], ignoretz=True)

            log_step = TextLogStep.objects.create(
                job=job,
                started_line_number=step['started_linenumber'],
                finished_line_number=step['finished_linenumber'],
                name=name,
                result=result_map[step['result']],
                **time_kwargs)

            if step.get('errors'):
                for error in step['errors']:
                    TextLogError.objects.create(
                        step=log_step,
                        line_number=error['linenumber'],
                        line=astral_filter(error['line']))

    # get error summary immediately (to warm the cache)
    error_summary.get_error_summary(job)
def store_text_log_summary_artifact ( job , text_log_summary_artifact ) : step_data = json . loads ( text_log_summary_artifact [ 'blob' ] ) [ 'step_data' ] result_map = { v : k for ( k , v ) in TextLogStep . RESULTS } with transaction . atomic ( ) : for step in step_data [ 'steps' ] : name = step [ 'name' ] [ : TextLogStep . _meta . get_field ( 'name' ) . max_length ] time_kwargs = { } for tkey in ( 'started' , 'finished' ) : if step . get ( tkey ) : time_kwargs [ tkey ] = dateutil . parser . parse ( step [ tkey ] , ignoretz = True ) log_step = TextLogStep . objects . create ( job = job , started_line_number = step [ 'started_linenumber' ] , finished_line_number = step [ 'finished_linenumber' ] , name = name , result = result_map [ step [ 'result' ] ] , ** time_kwargs ) if step . get ( 'errors' ) : for error in step [ 'errors' ] : TextLogError . objects . create ( step = log_step , line_number = error [ 'linenumber' ] , line = astral_filter ( error [ 'line' ] ) ) error_summary . get_error_summary ( job )
Store the contents of the text log summary artifact