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 os
from optparse import make_option
from django.core.management.base import BaseCommand
@ -19,26 +18,44 @@ def deprecate_periodic_tasks(names):
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'
# This command must be able to run in an environment with unsatisfied dependencies
leave_locale_alone = True
can_import_settings = 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
def handle(self, *args, **options):
version = options.get('version')

View file

@ -1,5 +1,4 @@
import textwrap
from optparse import make_option
from os import path
from django.core.management.base import BaseCommand
@ -10,21 +9,33 @@ from orchestra.utils.sys import run, check_root
class Command(BaseCommand):
help = 'Configure Celeryd to run with your orchestra instance.'
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.'
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
def handle(self, *args, **options):

View file

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

View file

@ -1,52 +1,97 @@
import os
from optparse import make_option
from django.core.management.base import BaseCommand
from orchestra.utils.sys import run, check_root
class Command(BaseCommand):
help = 'Setup Postfix.'
def __init__(self, *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',
help='Specifies username in the operating system (default=vmail).'),
make_option('--vmail_uid', dest='vmail_uid', default='5000',
help='UID of user <vmail_username> (default=5000).'),
make_option('--vmail_groupname', dest='vmail_groupname', default='vmail',
help='Specifies the groupname in the operating system (default=vmail).'),
make_option('--vmail_gid', dest='vmail_gid', default='5000',
help='GID of user <vmail_username> (default=5000).'),
make_option('--vmail_home', dest='vmail_home', default='/var/vmail',
help='$HOME of user <vmail_username> (default=/var/vmail).'),
make_option('--dovecot_dir', dest='dovecot_dir', default='/etc/dovecot',
help='Dovecot root directory (default=/etc/dovecot).'),
make_option('--postfix_dir', dest='postfix_dir', default='/etc/postfix',
help='Postfix root directory (default=/etc/postfix).'),
make_option('--amavis_dir', dest='amavis_dir', default='/etc/amavis',
help='Amavis root directory (default=/etc/amavis).'),
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 '
'cleeryd process owner, which is the user how will perform tincd updates'),
)
option_list = BaseCommand.option_list
help = 'Setup Postfix.'
def add_arguments(self, parser):
parser.add_argument(
'--db_name',
dest='db_name',
default='orchestra',
help='Specifies the database to create.'
)
parser.add_argument(
'--db_user',
dest='db_user',
default='orchestra',
help='Specifies the database to create.'
)
parser.add_argument(
'--db_password',
dest='db_password',
default='orchestra',
help='Specifies the database to create.'
)
parser.add_argument(
'--db_host',
dest='db_host',
default='localhost',
help='Specifies the database to create.'
)
parser.add_argument(
'--vmail_username',
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
def handle(self, *args, **options):

View file

@ -1,6 +1,5 @@
import os
import textwrap
from optparse import make_option
from django.conf import settings
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 orchestra import settings
@ -30,9 +28,16 @@ def flatten(nested, depth=0):
class ManageServiceCommand(BaseCommand):
def __init__(self, *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

View file

@ -3,7 +3,6 @@ import os
import random
import string
from distutils.sysconfig import get_python_lib
from optparse import make_option
from django.core.management import call_command
from django.core.management.base import BaseCommand, CommandError
@ -26,20 +25,28 @@ def get_existing_pip_installation():
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"
can_import_settings = False
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
def handle(self, *args, **options):
current_version = get_version()