1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

Merge pull request #1804 from ryanpetrello/stdout-format-json

never convert ANSI codes to HTML for format /stdout/?format=json
This commit is contained in:
Ryan Petrello 2018-05-16 11:41:20 -04:00 committed by GitHub
commit f287948efe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View File

@ -4764,7 +4764,6 @@ class UnifiedJobStdout(RetrieveAPIView):
try:
target_format = request.accepted_renderer.format
if target_format in ('html', 'api', 'json'):
content_format = request.query_params.get('content_format', 'html')
content_encoding = request.query_params.get('content_encoding', None)
start_line = request.query_params.get('start_line', 0)
end_line = request.query_params.get('end_line', None)
@ -4790,10 +4789,10 @@ class UnifiedJobStdout(RetrieveAPIView):
if target_format == 'api':
return Response(mark_safe(data))
if target_format == 'json':
if content_encoding == 'base64' and content_format == 'ansi':
return Response({'range': {'start': start, 'end': end, 'absolute_end': absolute_end}, 'content': b64encode(content.encode('utf-8'))})
elif content_format == 'html':
return Response({'range': {'start': start, 'end': end, 'absolute_end': absolute_end}, 'content': body})
content = content.encode('utf-8')
if content_encoding == 'base64':
content = b64encode(content)
return Response({'range': {'start': start, 'end': end, 'absolute_end': absolute_end}, 'content': content})
return Response(data)
elif target_format == 'txt':
return Response(unified_job.result_stdout)

View File

@ -282,7 +282,7 @@ def test_unicode_with_base64_ansi(sqlite_copy_expert, get, admin):
url = reverse(
'api:job_stdout',
kwargs={'pk': job.pk}
) + '?format=json&content_encoding=base64&content_format=ansi'
) + '?format=json&content_encoding=base64'
response = get(url, user=admin, expect=200)
content = base64.b64decode(json.loads(response.content)['content'])