Use argparse instead of optparse
Use of optparse module is deprecated [1] in Django 1.8 and 1.9 versions and
its support has been removed in currently developed version 1.10 [2]
[1] https://docs.djangoproject.com/en/1.9/howto/custom-management-commands/#django.core.management.BaseCommand.option_list
[2] 6a70cb5397 (diff-dfc45ab8548a0777543d12d6e77c9173)
Change-Id: I0c7622fce0d5fabce45366d002b5e72e4c170344
This commit is contained in:
parent
528358cbbd
commit
374e60307d
@ -13,7 +13,6 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from optparse import make_option # noqa
|
||||
import os
|
||||
import re
|
||||
import socket
|
||||
@ -165,76 +164,100 @@ location you desire, e.g.::
|
||||
'admin': context['ADMIN'],
|
||||
'hostname': context['VHOSTNAME'], }
|
||||
|
||||
option_list = BaseCommand.option_list + (
|
||||
def add_arguments(self, parser):
|
||||
# TODO(ygbo): Add an --nginx option.
|
||||
make_option("-a", "--apache",
|
||||
default=False, action="store_true", dest="apache",
|
||||
help="generate an apache vhost configuration"),
|
||||
make_option("--cacert",
|
||||
dest="cacert",
|
||||
help=("Use with the --apache and --ssl option to define "
|
||||
"the path to the SSLCACertificateFile"
|
||||
),
|
||||
metavar="CACERT"),
|
||||
make_option("-f", "--force",
|
||||
default=False, action="store_true", dest="force",
|
||||
help="force overwriting of an existing %s file" %
|
||||
context['WSGI_FILE']),
|
||||
make_option("-H", "--hostname",
|
||||
dest="hostname",
|
||||
help=("Use with the --apache option to define the server's"
|
||||
" hostname (default : %s)") % context['VHOSTNAME'],
|
||||
metavar="HOSTNAME"),
|
||||
make_option("--logdir",
|
||||
dest="logdir",
|
||||
help=("Use with the --apache option to define the path to "
|
||||
"the apache log directory(default : %s)"
|
||||
% context['LOGDIR']),
|
||||
metavar="CACERT"),
|
||||
make_option("-m", "--mail",
|
||||
dest="mail",
|
||||
help=("Use with the --apache option to define the web site"
|
||||
" administrator's email (default : %s)") %
|
||||
context['ADMIN'],
|
||||
metavar="MAIL"),
|
||||
make_option("-n", "--namedhost",
|
||||
default=False, action="store_true", dest="namedhost",
|
||||
help=("Use with the --apache option. The apache vhost "
|
||||
"configuration will work only when accessed with "
|
||||
"the proper hostname (see --hostname).")),
|
||||
make_option("-p", "--project",
|
||||
dest="project",
|
||||
help=("Use with the --apache option to define the project "
|
||||
"name (default : %s)") % context['PROJECT_NAME'],
|
||||
metavar="PROJECT"),
|
||||
make_option("-s", "--ssl",
|
||||
default=False, action="store_true", dest="ssl",
|
||||
help=("Use with the --apache option. The apache vhost "
|
||||
"configuration will use an SSL configuration")),
|
||||
make_option("--sslcert",
|
||||
dest="sslcert",
|
||||
help=("Use with the --apache and --ssl option to define "
|
||||
"the path to the SSLCertificateFile (default : %s)"
|
||||
) % context['SSLCERT'],
|
||||
metavar="SSLCERT"),
|
||||
make_option("--sslkey",
|
||||
dest="sslkey",
|
||||
help=("Use with the --apache and --ssl option to define "
|
||||
"the path to the SSLCertificateKeyFile "
|
||||
"(default : %s)") % context['SSLKEY'],
|
||||
metavar="SSLKEY"),
|
||||
make_option("--apache-version",
|
||||
dest="apache_version",
|
||||
type="float",
|
||||
help=("Use with the --apache option to define the apache "
|
||||
"major (as a floating point number) version "
|
||||
"(default : %s)."
|
||||
% context['APACHE2_VERSION']),
|
||||
metavar="APACHE_VERSION"),
|
||||
make_option("-w", "--wsgi",
|
||||
default=False, action="store_true", dest="wsgi",
|
||||
help="generate the horizon.wsgi file"),
|
||||
)
|
||||
parser.add_argument(
|
||||
"-a", "--apache",
|
||||
default=False, action="store_true", dest="apache",
|
||||
help="generate an apache vhost configuration"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--cacert",
|
||||
dest="cacert",
|
||||
help=("Use with the --apache and --ssl option to define the path"
|
||||
" to the SSLCACertificateFile"),
|
||||
metavar="CACERT"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-f", "--force",
|
||||
default=False, action="store_true", dest="force",
|
||||
help="force overwriting of an existing %s file" %
|
||||
context['WSGI_FILE']
|
||||
)
|
||||
parser.add_argument(
|
||||
"-H", "--hostname",
|
||||
dest="hostname",
|
||||
help=("Use with the --apache option to define the server's"
|
||||
" hostname (default : %s)") % context['VHOSTNAME'],
|
||||
metavar="HOSTNAME"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--logdir",
|
||||
dest="logdir",
|
||||
help=("Use with the --apache option to define the path to "
|
||||
"the apache log directory(default : %s)"
|
||||
% context['LOGDIR']),
|
||||
metavar="CACERT"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-m", "--mail",
|
||||
dest="mail",
|
||||
help=("Use with the --apache option to define the web site"
|
||||
" administrator's email (default : %s)") %
|
||||
context['ADMIN'],
|
||||
metavar="MAIL"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-n", "--namedhost",
|
||||
default=False, action="store_true", dest="namedhost",
|
||||
help=("Use with the --apache option. The apache vhost "
|
||||
"configuration will work only when accessed with "
|
||||
"the proper hostname (see --hostname).")
|
||||
)
|
||||
parser.add_argument(
|
||||
"-p", "--project",
|
||||
dest="project",
|
||||
help=("Use with the --apache option to define the project "
|
||||
"name (default : %s)") % context['PROJECT_NAME'],
|
||||
metavar="PROJECT"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-s", "--ssl",
|
||||
default=False, action="store_true", dest="ssl",
|
||||
help=("Use with the --apache option. The apache vhost "
|
||||
"configuration will use an SSL configuration")
|
||||
)
|
||||
parser.add_argument(
|
||||
"--sslcert",
|
||||
dest="sslcert",
|
||||
help=("Use with the --apache and --ssl option to define "
|
||||
"the path to the SSLCertificateFile (default : %s)"
|
||||
) % context['SSLCERT'],
|
||||
metavar="SSLCERT"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--sslkey",
|
||||
dest="sslkey",
|
||||
help=("Use with the --apache and --ssl option to define "
|
||||
"the path to the SSLCertificateKeyFile "
|
||||
"(default : %s)") % context['SSLKEY'],
|
||||
metavar="SSLKEY"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--apache-version",
|
||||
dest="apache_version",
|
||||
type=float,
|
||||
help=("Use with the --apache option to define the apache "
|
||||
"major (as a floating point number) version "
|
||||
"(default : %s)."
|
||||
% context['APACHE2_VERSION']),
|
||||
metavar="APACHE_VERSION"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-w", "--wsgi",
|
||||
default=False, action="store_true", dest="wsgi",
|
||||
help="generate the horizon.wsgi file"
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
force = options.get('force')
|
||||
|
@ -14,7 +14,6 @@ from __future__ import print_function
|
||||
|
||||
import difflib
|
||||
import imp
|
||||
import optparse
|
||||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
@ -75,24 +74,23 @@ class DirContext(object):
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
option_list = BaseCommand.option_list + (
|
||||
optparse.make_option(
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--gendiff',
|
||||
action='store_true',
|
||||
dest='gendiff',
|
||||
default=False,
|
||||
help=('Generate a diff file between local_settings.py and '
|
||||
'local_settings.py.example'),
|
||||
),
|
||||
optparse.make_option(
|
||||
)
|
||||
parser.add_argument(
|
||||
'-f', '--force',
|
||||
action='store_true',
|
||||
dest='force',
|
||||
default=False,
|
||||
help=('Force destination rewriting without warning if the '
|
||||
'destination file already exists.'),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
help = ("Creates a local_settings.py file from the "
|
||||
"local_settings.py.example template.")
|
||||
|
Loading…
Reference in New Issue
Block a user