mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-23 06:38:12 +08:00
adds qinfo management command
It seems more practical to give this its own command instead of `qmonitor --info`
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from django_q.monitor import info
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
# Translators: help text for qinfo management command
|
||||
help = _('General information over all clusters.')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
info()
|
||||
@@ -1,10 +1,9 @@
|
||||
# Django
|
||||
from optparse import make_option
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from django_q.monitor import monitor, info
|
||||
from django_q.monitor import monitor
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
@@ -17,16 +16,7 @@ class Command(BaseCommand):
|
||||
dest='run_once',
|
||||
default=False,
|
||||
help='Run once and then stop.'),
|
||||
make_option('-i', '--info',
|
||||
action='store_true',
|
||||
dest='info',
|
||||
default=False,
|
||||
help='Lists general information over all clusters. ')
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
if options.get('info', False):
|
||||
info()
|
||||
else:
|
||||
monitor(run_once=options.get('run_once', False))
|
||||
|
||||
monitor(run_once=options.get('run_once', False))
|
||||
|
||||
+1
-1
@@ -201,7 +201,7 @@ def info(r=redis_client):
|
||||
reincarnations += cluster.reincarnations
|
||||
term.clear_eos()
|
||||
col_width = int(term.width / 6)
|
||||
print(term.black_on_green(term.center(_('-- {} clusters summary --').format(Conf.PREFIX))))
|
||||
print(term.black_on_green(term.center(_('-- {} summary --').format(Conf.PREFIX))))
|
||||
print(term.cyan(_('Clusters')) +
|
||||
term.move_x(1 * col_width) +
|
||||
term.white(str(clusters)) +
|
||||
|
||||
@@ -6,7 +6,12 @@ from django.core.management import call_command
|
||||
def test_qcluster():
|
||||
call_command('qcluster', run_once=True)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_qmonitor():
|
||||
call_command('qmonitor', run_once=True)
|
||||
call_command('qmonitor', info=True)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_qinfo():
|
||||
call_command('qinfo')
|
||||
|
||||
@@ -2,7 +2,7 @@ import pytest
|
||||
import redis
|
||||
|
||||
from django_q.cluster import Cluster
|
||||
from django_q.monitor import monitor, Stat, info, ping_redis
|
||||
from django_q.monitor import monitor, Stat, ping_redis
|
||||
|
||||
|
||||
def test_monitor():
|
||||
|
||||
Reference in New Issue
Block a user