Really try to emulate the logs format with the test logs. Switch to a simplified flat logs format.

This commit is contained in:
yackob03 2014-02-12 18:58:40 -05:00
parent 85694dd110
commit b920a0cb1f
4 changed files with 187 additions and 196 deletions

View file

@ -1190,38 +1190,12 @@ def get_repo_build_logs(namespace, repository, build_uuid):
build = model.get_repository_build(namespace, repository, build_uuid)
start_param = request.args.get('start', None)
end = int(request.args.get('end', -1))
start = int(request.args.get('start', 0))
last_command = None
include_commands = request.args.get('commands', 'false')
if include_commands.lower() not in {'0', 'false'}:
commands = [cmd for cmd in build_logs.get_commands(build.uuid)]
response_obj['commands'] = commands
if commands:
last_command = commands[-1]
elif start_param is None:
last_command = build_logs.get_last_command(build.uuid)
if start_param is None:
if last_command:
start = last_command['index']
else:
start = 0
else:
start = int(start_param)
count, logs = build_logs.get_log_entries(build.uuid, start, end)
if start < 0:
start = max(0, count + start)
if end < 0:
end = count + end
count, logs = build_logs.get_log_entries(build.uuid, start)
response_obj.update({
'start': start,
'end': end,
'total': count,
'logs': [log for log in logs],
})