fixed
This commit is contained in:
parent
7c62092faa
commit
78db4fb8d5
|
@ -11,65 +11,65 @@ from orchestra.utils.sys import run, check_root
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
|
help = 'Setup PostgreSQL database.'
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Command, self).__init__(*args, **kwargs)
|
super(Command, self).__init__(*args, **kwargs)
|
||||||
# Get defaults from settings, if exists
|
# Get defaults from settings, if exists
|
||||||
try:
|
try:
|
||||||
defaults = settings.DATABASES['default']
|
self.defaults = settings.DATABASES['default']
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
defaults = {}
|
defaults = {}
|
||||||
else:
|
else:
|
||||||
if defaults['ENGINE'] != 'django.db.backends.postgresql_psycopg2':
|
if self.defaults['ENGINE'] != 'django.db.backends.postgresql_psycopg2':
|
||||||
defaults = {}
|
self.defaults = {}
|
||||||
|
|
||||||
def add_arguments(self, parser):
|
def add_arguments(self, parser):
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--db_name',
|
'--db_name',
|
||||||
dest='db_name',
|
dest='db_name',
|
||||||
default=defaults.get('DB_NAME', 'orchestra'),
|
default=self.defaults.get('DB_NAME', 'orchestra'),
|
||||||
help='Specifies the database to create.',
|
help='Specifies the database to create.',
|
||||||
type=str
|
type=str
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--db_user',
|
'--db_user',
|
||||||
dest='db_user',
|
dest='db_user',
|
||||||
default=defaults.get('DB_USER', 'orchestra'),
|
default=self.defaults.get('DB_USER', 'orchestra'),
|
||||||
help='Specifies the database to create.',
|
help='Specifies the database to create.',
|
||||||
type=str
|
type=str
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--db_password',
|
'--db_password',
|
||||||
dest='db_password',
|
dest='db_password',
|
||||||
default=defaults.get('PASSWORD', ''),
|
default=self.defaults.get('PASSWORD', ''),
|
||||||
help='Specifies the database password, random if not specified.',
|
help='Specifies the database password, random if not specified.',
|
||||||
type=str
|
type=str
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--db_host',
|
'--db_host',
|
||||||
dest='db_host',
|
dest='db_host',
|
||||||
default=defaults.get('HOST', 'localhost'),
|
default=slef.defaults.get('HOST', 'localhost'),
|
||||||
help='Specifies the database to create.',
|
help='Specifies the database to create.',
|
||||||
type=str
|
type=str
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--db_port',
|
'--db_port',
|
||||||
dest='db_port',
|
dest='db_port',
|
||||||
default=defaults.get('PORT', '5432'),
|
default=self.defaults.get('PORT', '5432'),
|
||||||
help='Specifies the database to create.',
|
help='Specifies the database to create.',
|
||||||
type=str
|
type=str
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--noinput',
|
'--noinput',
|
||||||
action='store_false',
|
action='store_false',
|
||||||
dest='interactive',
|
dest='interactive',
|
||||||
default=True,
|
default=True,
|
||||||
help='Tells Django to NOT prompt the user for input of any kind. '
|
help='Tells Django to NOT prompt the user for input of any kind. '
|
||||||
'You must use --username with --noinput, and must contain the '
|
'You must use --username with --noinput, and must contain the '
|
||||||
'cleeryd process owner, which is the user how will perform tincd updates',
|
'cleeryd process owner, which is the user how will perform tincd updates',
|
||||||
type=str
|
type=str
|
||||||
)
|
)
|
||||||
|
|
||||||
help = 'Setup PostgreSQL database.'
|
|
||||||
|
|
||||||
def run_postgres(self, cmd, *args, **kwargs):
|
def run_postgres(self, cmd, *args, **kwargs):
|
||||||
return run('su postgres -c "psql -c \\"%s\\""' % cmd, *args, **kwargs)
|
return run('su postgres -c "psql -c \\"%s\\""' % cmd, *args, **kwargs)
|
||||||
|
|
Loading…
Reference in New Issue