update BaseCommand option_list for Django 1.11
This commit is contained in:
parent
81370d15fe
commit
2b5f0e9f05
@ -4,8 +4,6 @@ dealing with domains (Domain records in our database)
|
||||
|
||||
import dns.resolver
|
||||
|
||||
from optparse import make_option
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.mail import send_mail
|
||||
from django.db import transaction
|
||||
@ -15,7 +13,6 @@ from nsupdate.main.models import Domain
|
||||
from nsupdate.main.dnstools import FQDN, query_ns, NameServerNotAvailable
|
||||
from nsupdate.utils.mail import translate_for_user, send_mail_to_user
|
||||
|
||||
|
||||
MSG = _("""\
|
||||
Your domain: %(domain)s (comment: %(comment)s)
|
||||
|
||||
@ -68,20 +65,17 @@ def check_dns(domain):
|
||||
class Command(BaseCommand):
|
||||
help = 'deal with domains'
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('--check',
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('--check',
|
||||
action='store_true',
|
||||
dest='check',
|
||||
default=False,
|
||||
help='check whether nameserver for domain is reachable and answers queries',
|
||||
),
|
||||
make_option('--notify-user',
|
||||
help='check whether nameserver for domain is reachable and answers queries')
|
||||
parser.add_argument('--notify-user',
|
||||
action='store_true',
|
||||
dest='notify_user',
|
||||
default=False,
|
||||
help='notify the user by email when domain gets flagged as unavailable',
|
||||
),
|
||||
)
|
||||
help='notify the user by email when domain gets flagged as unavailable')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
check = options['check']
|
||||
|
@ -4,8 +4,6 @@ dealing with the fault counters and available/abuse/abuse_blocked flags
|
||||
|
||||
import traceback
|
||||
|
||||
from optparse import make_option
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.mail import send_mail
|
||||
from django.db import transaction
|
||||
@ -52,63 +50,53 @@ Notes:
|
||||
class Command(BaseCommand):
|
||||
help = 'deal with the faults counters'
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('--show-server',
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('--show-server',
|
||||
action='store_true',
|
||||
dest='show_server',
|
||||
default=False,
|
||||
help='show server fault counters',
|
||||
),
|
||||
make_option('--show-client',
|
||||
help='show server fault counters')
|
||||
parser.add_argument('--show-client',
|
||||
action='store_true',
|
||||
dest='show_client',
|
||||
default=False,
|
||||
help='show client fault counters',
|
||||
),
|
||||
make_option('--reset-server',
|
||||
help='show client fault counters')
|
||||
parser.add_argument('--reset-server',
|
||||
action='store_true',
|
||||
dest='reset_server',
|
||||
default=False,
|
||||
help='reset the server fault counters of all hosts',
|
||||
),
|
||||
make_option('--reset-client',
|
||||
help='reset the server fault counters of all hosts')
|
||||
parser.add_argument('--reset-client',
|
||||
action='store_true',
|
||||
dest='reset_client',
|
||||
default=False,
|
||||
help='reset the client fault counters of all hosts',
|
||||
),
|
||||
make_option('--reset-abuse',
|
||||
help='reset the client fault counters of all hosts')
|
||||
parser.add_argument('--reset-abuse',
|
||||
action='store_true',
|
||||
dest='reset_abuse',
|
||||
default=False,
|
||||
help='reset the abuse flag (to False) of all hosts',
|
||||
),
|
||||
make_option('--reset-abuse-blocked',
|
||||
help='reset the abuse flag (to False) of all hosts')
|
||||
parser.add_argument('--reset-abuse-blocked',
|
||||
action='store_true',
|
||||
dest='reset_abuse_blocked',
|
||||
default=False,
|
||||
help='reset the abuse_blocked flag (to False) of all hosts',
|
||||
),
|
||||
make_option('--reset-available',
|
||||
help='reset the abuse_blocked flag (to False) of all hosts')
|
||||
parser.add_argument('--reset-available',
|
||||
action='store_true',
|
||||
dest='reset_available',
|
||||
default=False,
|
||||
help='reset the available flag (to True) of all hosts',
|
||||
),
|
||||
make_option('--flag-abuse',
|
||||
help='reset the available flag (to True) of all hosts')
|
||||
parser.add_argument('--flag-abuse',
|
||||
action='store',
|
||||
dest='flag_abuse',
|
||||
default=None,
|
||||
type='int',
|
||||
help='if client faults > N then set abuse flag and reset client faults',
|
||||
),
|
||||
make_option('--notify-user',
|
||||
help='if client faults > N then set abuse flag and reset client faults')
|
||||
parser.add_argument('--notify-user',
|
||||
action='store_true',
|
||||
dest='notify_user',
|
||||
default=False,
|
||||
help='notify the user by email when host gets flagged for abuse',
|
||||
),
|
||||
)
|
||||
help='notify the user by email when host gets flagged for abuse')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
show_client = options['show_client']
|
||||
|
@ -3,7 +3,6 @@ dealing with hosts (Host records in our database)
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
from optparse import make_option
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db import transaction
|
||||
@ -132,20 +131,17 @@ def check_staleness(h):
|
||||
class Command(BaseCommand):
|
||||
help = 'deal with hosts'
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option('--stale-check',
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('--stale-check',
|
||||
action='store_true',
|
||||
dest='stale_check',
|
||||
default=False,
|
||||
help='check whether the host has been updated recently, increase staleness counter if not',
|
||||
),
|
||||
make_option('--notify-user',
|
||||
help='check whether the host has been updated recently, increase staleness counter if not')
|
||||
parser.add_argument('--notify-user',
|
||||
action='store_true',
|
||||
dest='notify_user',
|
||||
default=False,
|
||||
help='notify the user by email when staleness counter increases',
|
||||
),
|
||||
)
|
||||
help='notify the user by email when staleness counter increases')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
stale_check = options['stale_check']
|
||||
|
@ -4,13 +4,13 @@ reinitialize the test user account (and clean up)
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.management.base import NoArgsCommand
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
class Command(BaseCommand):
|
||||
help = 'reinitialize the test user'
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
def handle(self, *args, **options):
|
||||
user_model = get_user_model()
|
||||
try:
|
||||
u = user_model.objects.get(username='test')
|
||||
|
Loading…
x
Reference in New Issue
Block a user