multitenant: improve cron messages (#57526)

This commit is contained in:
Emmanuel Cazenave 2021-10-05 11:55:44 +02:00 committed by Benjamin Dauvergne
parent 026cfba744
commit d4123343d8
1 changed files with 7 additions and 3 deletions

View File

@ -111,6 +111,10 @@ class Command(InteractiveTenantOption, BaseCommand):
help='Run command even if DISABLE_CRON_JOBS is set',
)
args_namespace, args = args_parser.parse_known_args(argv)
try:
command = args[1]
except IndexError:
command = '(unknown)'
# Continue weirdness: parse verbosity option and also leave it in args
# for subcommand consumption
@ -126,7 +130,7 @@ class Command(InteractiveTenantOption, BaseCommand):
and getattr(settings, 'DISABLE_CRON_JOBS', False)
):
if args_verbosity.verbosity > 1:
print('Command %s is ignored because DISABLE_CRON_JOBS is set' % app_name)
print('Command %s is ignored because DISABLE_CRON_JOBS is set' % command)
return
if args_namespace.all_tenants:
@ -136,7 +140,7 @@ class Command(InteractiveTenantOption, BaseCommand):
if getattr(settings, 'TENANT_DISABLE_CRON_JOBS', False):
if args_verbosity.verbosity > 1 or args_namespace.force_job:
msg = 'Command %s is ignored on tenant %s because TENANT_DISABLE_CRON_JOBS is set' % (
app_name,
command,
tenant.domain_url,
)
prefix = '* '
@ -145,7 +149,7 @@ class Command(InteractiveTenantOption, BaseCommand):
print(prefix + msg)
continue
if args_verbosity.verbosity > 1:
print(u'* Running command on tenant %s' % tenant.domain_url)
print(u'* Running command %s on tenant %s' % (command, tenant.domain_url))
error = run_command_from_argv(klass, args)
if error:
errors.append(error)