mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 11:27:36 -02:30
Efficient stdout downloader implementation
* Temporarily dump stdout contents to a configurable temp location * Implement file streaming to the host via a new format specifier in the api view
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
import codecs
|
||||
import json
|
||||
import logging
|
||||
import uuid
|
||||
import re
|
||||
import os
|
||||
import os.path
|
||||
@@ -664,6 +665,15 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
|
||||
record_size = cursor.fetchone()[0]
|
||||
return record_size
|
||||
|
||||
def dump_result_stdout(self):
|
||||
tower_file = "towerjob-%s" % str(uuid.uuid1())[:8]
|
||||
out_path = os.path.join(settings.STDOUT_TEMP_DIR, tower_file)
|
||||
tower_fd = open(out_path, 'w')
|
||||
cursor = connection.cursor()
|
||||
cursor.copy_expert("copy (select result_stdout_text from main_unifiedjob where id = %d) to stdout" % (self.pk), tower_fd)
|
||||
tower_fd.close()
|
||||
return out_path
|
||||
|
||||
def _result_stdout_raw_limited(self, start_line=0, end_line=None, redact_sensitive=True, escape_ascii=False):
|
||||
return_buffer = u""
|
||||
if end_line is not None:
|
||||
|
||||
Reference in New Issue
Block a user