fixed make_options for all commands

This commit is contained in:
Cayo Puigdefabregas 2021-01-30 14:59:49 +01:00
parent 8da89ae22a
commit 6ce4d6b877
7 changed files with 172 additions and 89 deletions

View File

@ -1,6 +1,5 @@
import re import re
import os import os
from optparse import make_option
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
@ -19,26 +18,44 @@ def deprecate_periodic_tasks(names):
class Command(BaseCommand): class Command(BaseCommand):
def __init__(self, *args, **kwargs):
super(Command, self).__init__(*args, **kwargs)
self.option_list = BaseCommand.option_list + (
make_option('--no-restart', action='store_false', dest='restart', default=True,
help='Only install local requirements'),
make_option('--specifics', action='store_true', dest='specifics_only',
default=False, help='Only run version specific operations'),
make_option('--no-upgrade-notes', action='store_false', default=True,
dest='print_upgrade_notes', help='Do not print specific upgrade notes'),
make_option('--from', dest='version', default=False,
help="Orchestra's version from where you are upgrading, i.e 0.0.1"),
)
option_list = BaseCommand.option_list
help = 'Upgrades django-orchestra installation' help = 'Upgrades django-orchestra installation'
# This command must be able to run in an environment with unsatisfied dependencies # This command must be able to run in an environment with unsatisfied dependencies
leave_locale_alone = True leave_locale_alone = True
can_import_settings = False can_import_settings = False
requires_model_validation = False requires_model_validation = False
def __init__(self, *args, **kwargs):
super(Command, self).__init__(*args, **kwargs)
def add_arguments(self, parser):
parser.add_argument(
'--no-restart',
action='store_false',
dest='restart',
default=True,
help='Only install local requirements'
)
parser.add_argument(
'--specifics',
action='store_true',
dest='specifics_only',
default=False,
help='Only run version specific operations'
)
parser.add_argument(
'--no-upgrade-notes',
action='store_false',
default=True,
dest='print_upgrade_notes',
help='Do not print specific upgrade notes'
)
parser.add_argument(
'--from',
dest='version',
default=False,
help="Orchestra's version from where you are upgrading, i.e 0.0.1"
)
@check_root @check_root
def handle(self, *args, **options): def handle(self, *args, **options):
version = options.get('version') version = options.get('version')

View File

@ -1,5 +1,4 @@
import textwrap import textwrap
from optparse import make_option
from os import path from os import path
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
@ -10,22 +9,34 @@ from orchestra.utils.sys import run, check_root
class Command(BaseCommand): class Command(BaseCommand):
def __init__(self, *args, **kwargs):
super(Command, self).__init__(*args, **kwargs)
self.option_list = BaseCommand.option_list + (
make_option('--username', dest='username', default='orchestra',
help='Specifies the system user that would run celeryd.'),
make_option('--processes', dest='processes', default=2,
help='Number of celeryd processes.'),
make_option('--noinput', action='store_false', dest='interactive', default=True,
help='Tells Django to NOT prompt the user for input of any kind. '
'You must use --username with --noinput, and must contain the '
'cleleryd process owner, which is the user how will perform tincd updates'),
)
option_list = BaseCommand.option_list
help = 'Configure Celeryd to run with your orchestra instance.' help = 'Configure Celeryd to run with your orchestra instance.'
def __init__(self, *args, **kwargs):
super(Command, self).__init__(*args, **kwargs)
def add_arguments(self, parser):
parser.add_argument(
'--username',
dest='username',
default='orchestra',
help='Specifies the system user that would run celeryd.'
)
parser.add_argument(
'--processes',
dest='processes',
default=2,
help='Number of celeryd processes.'
)
parser.add_argument(
'--noinput',
action='store_false',
dest='interactive',
default=True,
help='''Tells Django to NOT prompt the user for input of any kind.
You must use --username with --noinput, and must contain the
cleleryd process owner, which is the user how will perform tincd updates'''
)
@check_root @check_root
def handle(self, *args, **options): def handle(self, *args, **options):
context = { context = {

View File

@ -1,6 +1,5 @@
import os import os
import textwrap import textwrap
from optparse import make_option
from os.path import expanduser from os.path import expanduser
from django.conf import settings from django.conf import settings

View File

@ -1,52 +1,97 @@
import os import os
from optparse import make_option
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from orchestra.utils.sys import run, check_root from orchestra.utils.sys import run, check_root
class Command(BaseCommand): class Command(BaseCommand):
help = 'Setup Postfix.'
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(Command, self).__init__(*args, **kwargs) super(Command, self).__init__(*args, **kwargs)
self.option_list = BaseCommand.option_list + (
make_option('--db_name', dest='db_name', default='orchestra',
help='Specifies the database to create.'),
make_option('--db_user', dest='db_user', default='orchestra',
help='Specifies the database to create.'),
make_option('--db_password', dest='db_password', default='orchestra',
help='Specifies the database to create.'),
make_option('--db_host', dest='db_host', default='localhost',
help='Specifies the database to create.'),
make_option('--vmail_username', dest='vmail_username', default='vmail', def add_arguments(self, parser):
help='Specifies username in the operating system (default=vmail).'), parser.add_argument(
make_option('--vmail_uid', dest='vmail_uid', default='5000', '--db_name',
help='UID of user <vmail_username> (default=5000).'), dest='db_name',
make_option('--vmail_groupname', dest='vmail_groupname', default='vmail', default='orchestra',
help='Specifies the groupname in the operating system (default=vmail).'), help='Specifies the database to create.'
make_option('--vmail_gid', dest='vmail_gid', default='5000', )
help='GID of user <vmail_username> (default=5000).'), parser.add_argument(
make_option('--vmail_home', dest='vmail_home', default='/var/vmail', '--db_user',
help='$HOME of user <vmail_username> (default=/var/vmail).'), dest='db_user',
default='orchestra',
make_option('--dovecot_dir', dest='dovecot_dir', default='/etc/dovecot', help='Specifies the database to create.'
help='Dovecot root directory (default=/etc/dovecot).'), )
parser.add_argument(
make_option('--postfix_dir', dest='postfix_dir', default='/etc/postfix', '--db_password',
help='Postfix root directory (default=/etc/postfix).'), dest='db_password',
default='orchestra',
make_option('--amavis_dir', dest='amavis_dir', default='/etc/amavis', help='Specifies the database to create.'
help='Amavis root directory (default=/etc/amavis).'), )
parser.add_argument(
make_option('--noinput', action='store_false', dest='interactive', default=True, '--db_host',
help='Tells Django to NOT prompt the user for input of any kind. ' dest='db_host',
'You must use --username with --noinput, and must contain the ' default='localhost',
'cleeryd process owner, which is the user how will perform tincd updates'), help='Specifies the database to create.'
) )
parser.add_argument(
option_list = BaseCommand.option_list '--vmail_username',
help = 'Setup Postfix.' dest='vmail_username',
default='vmail',
help='Specifies username in the operating system (default=vmail).'
)
parser.add_argument(
'--vmail_uid',
dest='vmail_uid',
default='5000',
help='UID of user <vmail_username> (default=5000).'
)
parser.add_argument(
'--vmail_groupname',
dest='vmail_groupname',
default='vmail',
help='Specifies the groupname in the operating system (default=vmail).'
)
parser.add_argument(
'--vmail_gid',
dest='vmail_gid',
default='5000',
help='GID of user <vmail_username> (default=5000).'
)
parser.add_argument(
'--vmail_home',
dest='vmail_home',
default='/var/vmail',
help='$HOME of user <vmail_username> (default=/var/vmail).'
)
parser.add_argument(
'--dovecot_dir',
dest='dovecot_dir',
default='/etc/dovecot',
help='Dovecot root directory (default=/etc/dovecot).'
)
parser.add_argument(
'--postfix_dir',
dest='postfix_dir',
default='/etc/postfix',
help='Postfix root directory (default=/etc/postfix).'
)
parser.add_argument(
'--amavis_dir',
dest='amavis_dir',
default='/etc/amavis',
help='Amavis root directory (default=/etc/amavis).'
)
parser.add_argument(
'--noinput',
action='store_false',
dest='interactive',
default=True,
help='''Tells Django to NOT prompt the user for input of any kind.
You must use --username with --noinput, and must contain the
cleeryd process owner, which is the user how will perform tincd updates'''
)
@check_root @check_root
def handle(self, *args, **options): def handle(self, *args, **options):

View File

@ -1,6 +1,5 @@
import os import os
import textwrap import textwrap
from optparse import make_option
from django.conf import settings from django.conf import settings
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError

View File

@ -1,5 +1,3 @@
from optparse import make_option
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from orchestra import settings from orchestra import settings
@ -30,9 +28,16 @@ def flatten(nested, depth=0):
class ManageServiceCommand(BaseCommand): class ManageServiceCommand(BaseCommand):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(ManageServiceCommand, self).__init__(*args, **kwargs) super(ManageServiceCommand, self).__init__(*args, **kwargs)
self.option_list = BaseCommand.option_list + tuple(
make_option('--no-%s' % service, action='store_false', dest=service, default=True,
help='Do not %s %s' % (self.action, service)) for service in flatten(self.services) def add_arguments(self, parser):
for service in flatten(self.services):
parser.add_argument(
'--no-%s' % service,
action='store_false',
dest=service,
default=True,
help='Do not %s %s' % (self.action, service)
) )
@check_root @check_root

View File

@ -3,7 +3,6 @@ import os
import random import random
import string import string
from distutils.sysconfig import get_python_lib from distutils.sysconfig import get_python_lib
from optparse import make_option
from django.core.management import call_command from django.core.management import call_command
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
@ -26,20 +25,28 @@ def get_existing_pip_installation():
class Command(BaseCommand): class Command(BaseCommand):
def __init__(self, *args, **kwargs):
super(Command, self).__init__(*args, **kwargs)
self.option_list = BaseCommand.option_list + (
make_option('--pip_only', action='store_true', dest='pip_only', default=False,
help='Only run "pip install django-orchestra --upgrade"'),
make_option('--orchestra_version', dest='version', default=False,
help='Specifies what version of the Orchestra you want to install'),
)
option_list = BaseCommand.option_list
help = "Upgrading Orchestra's installation. Desired version is accepted as argument" help = "Upgrading Orchestra's installation. Desired version is accepted as argument"
can_import_settings = False can_import_settings = False
leave_locale_alone = True leave_locale_alone = True
def __init__(self, *args, **kwargs):
super(Command, self).__init__(*args, **kwargs)
def add_arguments(self, parser):
parser.add_argument(
'--pip_only',
action='store_true',
dest='pip_only',
default=False,
help='Only run "pip install django-orchestra --upgrade"'
)
parser.add_argument(
'--orchestra_version',
dest='version',
default=False,
help='Specifies what version of the Orchestra you want to install'
)
@check_root @check_root
def handle(self, *args, **options): def handle(self, *args, **options):
current_version = get_version() current_version = get_version()