misc: display details when using verbose cook (#39744)

This commit is contained in:
Frédéric Péters 2020-02-11 17:35:31 +01:00
parent 09c8ada5bc
commit 0e61667d24
1 changed files with 20 additions and 1 deletions

View File

@ -18,6 +18,7 @@ from __future__ import print_function
import json
import string
import subprocess
import sys
import time
import os
@ -63,6 +64,11 @@ class Command(BaseCommand):
self.verbosity = kwargs.get('verbosity')
self.timeout = kwargs.get('timeout')
self.permissive = kwargs.get('permissive')
if self.verbosity > 1:
try:
self.terminal_width = int(subprocess.check_output(['tput', 'cols']).strip())
except OSError:
self.terminal_width = 80
self.run_cook(recipe)
if self.verbosity:
print('All steps executed successfully. Your environment should now be ready.')
@ -100,6 +106,8 @@ class Command(BaseCommand):
services.extend(service_class.objects.all())
t0 = time.time()
i = 0
last_service_url = None
while len(services) > 0:
for service in services[:]:
if service.last_operational_success_timestamp:
@ -108,8 +116,19 @@ class Command(BaseCommand):
service.check_operational()
if len(services) == 0:
break
if self.verbosity:
if self.verbosity == 1:
sys.stderr.write('.')
elif self.verbosity > 1:
if last_service_url != services[0].base_url:
last_service_url = services[0].base_url
i = 0
elif i == (self.terminal_width - len(services[0].base_url) - 25):
i = 0
i += 1
sys.stderr.write('\rWaiting for %s ' % services[0].base_url)
sys.stderr.write('%5ds ' % (timeout - (time.time() - t0)))
sys.stderr.write('.' * i)
sys.stderr.flush()
time.sleep(0.5)
if time.time() - t0 > timeout:
if self.verbosity: