mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-19 02:48:16 +08:00
Django 1.7 doesn't like argparse for management commands.
Changed to optparse for compatibility
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
from optparse import make_option
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from django_q.cluster import Cluster
|
||||
|
||||
|
||||
@@ -7,16 +10,19 @@ class Command(BaseCommand):
|
||||
# Translators: help text for qcluster management command
|
||||
help = _("Starts a Django Q Cluster.")
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('--run-once',
|
||||
action='store_true',
|
||||
dest='run_once',
|
||||
default=False,
|
||||
help='Run once and then stop.'),
|
||||
)
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('--run-once',
|
||||
action='store_true',
|
||||
dest='run_once',
|
||||
default=False,
|
||||
help='Run once and then stop.')
|
||||
parser.add_argument('poll_id', nargs='+', type=int)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
q = Cluster()
|
||||
q.start()
|
||||
if options.get('run_once', False):
|
||||
q.stop()
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# Django
|
||||
from optparse import make_option
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
@@ -9,12 +11,13 @@ class Command(BaseCommand):
|
||||
# Translators: help text for qmonitor management command
|
||||
help = _("Monitors Q Cluster activity")
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('--run-once',
|
||||
action='store_true',
|
||||
dest='run_once',
|
||||
default=False,
|
||||
help='Run once and then exit.')
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('--run-once',
|
||||
action='store_true',
|
||||
dest='run_once',
|
||||
default=False,
|
||||
help='Run once and then stop.'),
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
monitor(run_once=options.get('run_once', False))
|
||||
|
||||
Reference in New Issue
Block a user