mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-08 13:58:11 +08:00
Adds --config option to qinfo command
Outputs current configuration constants
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
|
from optparse import make_option
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
|
from django_q.conf import Conf
|
||||||
from django_q.monitor import info
|
from django_q.monitor import info
|
||||||
|
|
||||||
|
|
||||||
@@ -8,5 +10,19 @@ class Command(BaseCommand):
|
|||||||
# Translators: help text for qinfo management command
|
# Translators: help text for qinfo management command
|
||||||
help = _('General information over all clusters.')
|
help = _('General information over all clusters.')
|
||||||
|
|
||||||
|
option_list = BaseCommand.option_list + (
|
||||||
|
make_option('--config',
|
||||||
|
action='store_true',
|
||||||
|
dest='config',
|
||||||
|
default=False,
|
||||||
|
help='Print current configuration.'),
|
||||||
|
)
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
info()
|
if options.get('config', False):
|
||||||
|
hide = ['conf', 'IDLE', 'STOPPING', 'STARTING', 'WORKING', 'SIGNAL_NAMES', 'STOPPED']
|
||||||
|
settings = [a for a in dir(Conf) if not a.startswith('__') and a not in hide]
|
||||||
|
for setting in settings:
|
||||||
|
self.stdout.write('{}: {}'.format(setting, getattr(Conf, setting)))
|
||||||
|
else:
|
||||||
|
info()
|
||||||
|
|||||||
@@ -15,3 +15,4 @@ def test_qmonitor():
|
|||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_qinfo():
|
def test_qinfo():
|
||||||
call_command('qinfo')
|
call_command('qinfo')
|
||||||
|
call_command('qinfo', config=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user