mirror of
https://github.com/ansible/awx.git
synced 2026-03-01 16:58:46 -03:30
Merge pull request #7133 from ryanpetrello/fix-7100
copy adhoc events properly for stdout downloads
This commit is contained in:
@@ -4362,8 +4362,18 @@ class UnifiedJobStdout(RetrieveAPIView):
|
|||||||
write_fd = open(unified_job.result_stdout_file, 'w')
|
write_fd = open(unified_job.result_stdout_file, 'w')
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
try:
|
try:
|
||||||
cursor.copy_expert("copy (select stdout from main_jobevent where job_id={} order by start_line) to stdout".format(unified_job.id),
|
tablename, related_name = {
|
||||||
write_fd)
|
Job: ('main_jobevent', 'job_id'),
|
||||||
|
AdHocCommand: ('main_adhoccommandevent', 'ad_hoc_command_id'),
|
||||||
|
}[unified_job.__class__]
|
||||||
|
cursor.copy_expert(
|
||||||
|
"copy (select stdout from {} where {}={} order by start_line) to stdout".format(
|
||||||
|
tablename,
|
||||||
|
related_name,
|
||||||
|
unified_job.id
|
||||||
|
),
|
||||||
|
write_fd
|
||||||
|
)
|
||||||
write_fd.close()
|
write_fd.close()
|
||||||
subprocess.Popen("sed -i 's/\\\\r\\\\n/\\n/g' {}".format(unified_job.result_stdout_file),
|
subprocess.Popen("sed -i 's/\\\\r\\\\n/\\n/g' {}".format(unified_job.result_stdout_file),
|
||||||
shell=True).wait()
|
shell=True).wait()
|
||||||
|
|||||||
Reference in New Issue
Block a user