Exiting with user friendly message and SystemExit()

If you return anything as string to sys.exit method, the system exit
status is one (i.e. failure).
Added user friendly print message and returned without any exit code.

Closes-Bug: #1747690

Change-Id: I107cc1ad4b8d6d0ebee1127fc1e57db55c7cd839
This commit is contained in:
shilpa.devharakar 2018-02-07 12:00:22 +05:30
parent abfa272c1f
commit 8682876a8b

View File

@ -113,7 +113,8 @@ class DbCommands(object):
db_migration.CONTRACT_BRANCH)
if (contract in curr_heads):
sys.exit(_('Database is up to date. No migrations needed.'))
print(_('Database is up to date. No migrations needed.'))
sys.exit()
try:
self.expand()
@ -168,7 +169,8 @@ class DbCommands(object):
sys.exit(_('Database expansion failed. Couldn\'t find head '
'revision of expand branch.'))
elif (contract_head in curr_heads):
sys.exit(_('Database is up to date. No migrations needed.'))
print(_('Database is up to date. No migrations needed.'))
sys.exit()
self._sync(version=expand_head)
@ -191,7 +193,8 @@ class DbCommands(object):
sys.exit(_('Database contraction failed. Couldn\'t find head '
'revision of contract branch.'))
elif (contract_head in curr_heads):
sys.exit(_('Database is up to date. No migrations needed.'))
print(_('Database is up to date. No migrations needed.'))
sys.exit()
expand_head = alembic_migrations.get_alembic_branch_head(
db_migration.EXPAND_BRANCH)
@ -225,7 +228,8 @@ class DbCommands(object):
db_migration.CONTRACT_BRANCH)
if (contract_head in curr_heads):
sys.exit(_('Database is up to date. No migrations needed.'))
print(_('Database is up to date. No migrations needed.'))
sys.exit()
expand_head = alembic_migrations.get_alembic_branch_head(
db_migration.EXPAND_BRANCH)