mirror of
https://github.com/ansible/awx.git
synced 2026-02-21 13:10:11 -03:30
respect --no-color in awx-manage bottleneck
This commit is contained in:
@@ -21,6 +21,9 @@ class Command(BaseCommand):
|
|||||||
threshold = options['threshold']
|
threshold = options['threshold']
|
||||||
history = options['history']
|
history = options['history']
|
||||||
ignore = options['ignore']
|
ignore = options['ignore']
|
||||||
|
colorize = True
|
||||||
|
if options.get('no_color') is True:
|
||||||
|
colorize = False
|
||||||
|
|
||||||
print('## ' + JobTemplate.objects.get(pk=jt).name + f' (last {history} runs)\n')
|
print('## ' + JobTemplate.objects.get(pk=jt).name + f' (last {history} runs)\n')
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
@@ -61,6 +64,7 @@ class Command(BaseCommand):
|
|||||||
host_counts = dict()
|
host_counts = dict()
|
||||||
warned = set()
|
warned = set()
|
||||||
print(f'slowest tasks (--threshold={threshold})\n---')
|
print(f'slowest tasks (--threshold={threshold})\n---')
|
||||||
|
|
||||||
for event in slowest_events:
|
for event in slowest_events:
|
||||||
_id, job_id, host, duration, task, action, playbook = event
|
_id, job_id, host, duration, task, action, playbook = event
|
||||||
playbook = playbook.rsplit('/')[-1]
|
playbook = playbook.rsplit('/')[-1]
|
||||||
@@ -73,7 +77,7 @@ class Command(BaseCommand):
|
|||||||
fastest_match = fastest.get((action, playbook))
|
fastest_match = fastest.get((action, playbook))
|
||||||
if fastest_match[2] != duration.total_seconds() and (host, action, playbook) not in warned:
|
if fastest_match[2] != duration.total_seconds() and (host, action, playbook) not in warned:
|
||||||
warned.add((host, action, playbook))
|
warned.add((host, action, playbook))
|
||||||
fastest_summary = f' \033[93m{fastest_match[1]} ran this in {fastest_match[2]}s at /api/v2/job_events/{fastest_match[0]}/\033[0m'
|
fastest_summary = ' ' + self.style.WARNING(f'{fastest_match[1]} ran this in {fastest_match[2]}s at /api/v2/job_events/{fastest_match[0]}/')
|
||||||
|
|
||||||
url = f'/api/v2/jobs/{job_id}/'
|
url = f'/api/v2/jobs/{job_id}/'
|
||||||
human_duration = str(duration).split('.')[0]
|
human_duration = str(duration).split('.')[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user