From 78db4fb8d5070e8ac52fc5493db85f3ee0494a0a Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Sat, 30 Jan 2021 13:55:27 +0100 Subject: [PATCH] fixed --- .../management/commands/setuppostgres.py | 102 +++++++++--------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/orchestra/management/commands/setuppostgres.py b/orchestra/management/commands/setuppostgres.py index 4dbaeb26..ff365a75 100644 --- a/orchestra/management/commands/setuppostgres.py +++ b/orchestra/management/commands/setuppostgres.py @@ -11,65 +11,65 @@ from orchestra.utils.sys import run, check_root class Command(BaseCommand): + help = 'Setup PostgreSQL database.' + def __init__(self, *args, **kwargs): super(Command, self).__init__(*args, **kwargs) # Get defaults from settings, if exists try: - defaults = settings.DATABASES['default'] + self.defaults = settings.DATABASES['default'] except (AttributeError, KeyError): defaults = {} else: - if defaults['ENGINE'] != 'django.db.backends.postgresql_psycopg2': - defaults = {} + if self.defaults['ENGINE'] != 'django.db.backends.postgresql_psycopg2': + self.defaults = {} - def add_arguments(self, parser): - parser.add_argument( - '--db_name', - dest='db_name', - default=defaults.get('DB_NAME', 'orchestra'), - help='Specifies the database to create.', - type=str - ) - parser.add_argument( - '--db_user', - dest='db_user', - default=defaults.get('DB_USER', 'orchestra'), - help='Specifies the database to create.', - type=str - ) - parser.add_argument( - '--db_password', - dest='db_password', - default=defaults.get('PASSWORD', ''), - help='Specifies the database password, random if not specified.', - type=str - ) - parser.add_argument( - '--db_host', - dest='db_host', - default=defaults.get('HOST', 'localhost'), - help='Specifies the database to create.', - type=str - ) - parser.add_argument( - '--db_port', - dest='db_port', - default=defaults.get('PORT', '5432'), - help='Specifies the database to create.', - type=str - ) - 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', - type=str - ) - - help = 'Setup PostgreSQL database.' + def add_arguments(self, parser): + parser.add_argument( + '--db_name', + dest='db_name', + default=self.defaults.get('DB_NAME', 'orchestra'), + help='Specifies the database to create.', + type=str + ) + parser.add_argument( + '--db_user', + dest='db_user', + default=self.defaults.get('DB_USER', 'orchestra'), + help='Specifies the database to create.', + type=str + ) + parser.add_argument( + '--db_password', + dest='db_password', + default=self.defaults.get('PASSWORD', ''), + help='Specifies the database password, random if not specified.', + type=str + ) + parser.add_argument( + '--db_host', + dest='db_host', + default=slef.defaults.get('HOST', 'localhost'), + help='Specifies the database to create.', + type=str + ) + parser.add_argument( + '--db_port', + dest='db_port', + default=self.defaults.get('PORT', '5432'), + help='Specifies the database to create.', + type=str + ) + 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', + type=str + ) def run_postgres(self, cmd, *args, **kwargs): return run('su postgres -c "psql -c \\"%s\\""' % cmd, *args, **kwargs)