mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-15 13:37:56 +08:00
Replaces optparse with argparse for commands
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
from optparse import make_option
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
@@ -10,13 +8,14 @@ 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.',
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
q = Cluster()
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
from optparse import make_option
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from django_q import VERSION
|
||||
@@ -13,13 +10,14 @@ class Command(BaseCommand):
|
||||
# Translators: help text for qinfo management command
|
||||
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 add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--config',
|
||||
action='store_true',
|
||||
dest='config',
|
||||
default=False,
|
||||
help='Print current configuration.',
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
if options.get('config', False):
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
from optparse import make_option
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
@@ -10,13 +8,14 @@ class Command(BaseCommand):
|
||||
# Translators: help text for qmonitor management command
|
||||
help = _("Monitors Q Cluster activity")
|
||||
|
||||
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.',
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
monitor(run_once=options.get('run_once', False))
|
||||
|
||||
Reference in New Issue
Block a user