Skip to content

Commit 7f17a4a

Browse files
author
Alexander Popov
committed
fix: change logic in bootstrap (option -d), PGPRO-4094
1 parent f188376 commit 7f17a4a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

mamonsu/lib/default_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
import os
44
import logging
5-
import getpass
5+
import os
66
import mamonsu.lib.platform as platform
77

88

99
class PgsqlConfig(object):
1010

1111
@staticmethod
1212
def default_user():
13-
user = os.environ.get('PGUSER') or getpass.getuser() or 'postgres'
13+
user = os.environ.get('PGUSER') or os.getlogin() or 'postgres'
1414
return user
1515

1616
@staticmethod
@@ -40,7 +40,7 @@ def default_app():
4040

4141
@staticmethod
4242
def default_db():
43-
database = os.environ.get('PGDATABASE') or os.environ.get('PGUSER') or getpass.getuser()
43+
database = os.environ.get('PGDATABASE') or os.environ.get('PGUSER') or os.getlogin()
4444
database = database or 'postgres'
4545
return database
4646

mamonsu/tools/bootstrap/start.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def __init__(self):
2626
group.add_option(
2727
'-d', '--dbname',
2828
dest='dbname',
29-
default=self.default_db(),
30-
help='database name to connect to (default: %default)')
29+
default=None,
30+
help='database name to connect')
3131
group.add_option(
3232
'-h', '--host',
3333
dest='hostname',
@@ -76,6 +76,9 @@ def __init__(self):
7676
parser.print_help()
7777
sys.exit(1)
7878

79+
if not self.args.dbname:
80+
self.args.dbname = self.args.username
81+
7982
# apply env
8083
os.environ['PGUSER'] = self.args.username
8184
os.environ['PGPASSWORD'] = self.args.password
@@ -145,6 +148,7 @@ def test_db(self, host_pre):
145148

146149
def run_deploy():
147150
args = Args()
151+
148152
if not args.try_configure_connect_to_pg():
149153
sys.exit(1)
150154

0 commit comments

Comments
 (0)