forked from rq/django-rq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
85 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from django.core.management.base import BaseCommand | ||
|
||
from django.utils.six.moves import input | ||
|
||
from django_rq import get_queue | ||
|
||
|
||
class Command(BaseCommand): | ||
""" | ||
Flushes the queue specified as argument | ||
""" | ||
help = __doc__ | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
'--noinput', '--no-input', action='store_false', | ||
dest='interactive', default=True, | ||
help='Tells Django to NOT prompt the user for input of any kind.', | ||
) | ||
parser.add_argument('--queue', '-q', dest='queue', default='default', | ||
help='Specify the queue [default]') | ||
|
||
def handle(self, *args, **options): | ||
verbosity = int(options.get('verbosity', 1)) | ||
interactive = options['interactive'] | ||
queue = get_queue(options.get('queue')) | ||
|
||
if interactive: | ||
confirm = input("""You have requested a flush the "%s" queue. | ||
Are you sure you want to do this? | ||
Type 'yes' to continue, or 'no' to cancel: """ % queue.name) | ||
else: | ||
confirm = 'yes' | ||
|
||
if confirm == 'yes': | ||
queue.empty() | ||
if verbosity: | ||
print('Queue "%s" flushed.' % queue.name) | ||
else: | ||
if verbosity: | ||
print("Flush cancelled.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters