Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always exit unsuccessfully with sys.exit #1481

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ Contributors:
* Andrew M. MacFie (amacfie)
* saucoide
* Chris Rose (offbyone/offby1)
* Chris Novakovic

Creator:
--------
Expand Down
4 changes: 4 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Features
--------
* Add a `--ping` command line option; allows pgcli to replace `pg_isready`

Bug fixes:
----------
* Avoid raising `NameError` when exiting unsuccessfully in some cases

4.1.0 (2024-03-09)
==================

Expand Down
14 changes: 7 additions & 7 deletions pgcli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ def connect_service(self, service, user):
click.secho(
f"service '{service}' was not found in {file}", err=True, fg="red"
)
exit(1)
sys.exit(1)
self.connect(
database=service_config.get("dbname"),
host=service_config.get("host"),
Expand Down Expand Up @@ -710,7 +710,7 @@ def should_ask_for_password(exc):
self.logger.handlers = logger_handlers
self.logger.error("traceback: %r", traceback.format_exc())
click.secho(str(e), err=True, fg="red")
exit(1)
sys.exit(1)
self.logger.handlers = logger_handlers

atexit.register(self.ssh_tunnel.stop)
Expand Down Expand Up @@ -763,7 +763,7 @@ def should_ask_for_password(exc):
self.logger.debug("Database connection failed: %r.", e)
self.logger.error("traceback: %r", traceback.format_exc())
click.secho(str(e), err=True, fg="red")
exit(1)
sys.exit(1)

self.pgexecute = pgexecute

Expand Down Expand Up @@ -1551,7 +1551,7 @@ def cli(
err=True,
fg="red",
)
exit(1)
sys.exit(1)

if ssh_tunnel and not SSH_TUNNEL_SUPPORT:
click.secho(
Expand All @@ -1560,7 +1560,7 @@ def cli(
err=True,
fg="red",
)
exit(1)
sys.exit(1)

pgcli = PGCli(
prompt_passwd,
Expand Down Expand Up @@ -1604,15 +1604,15 @@ def cli(
err=True,
fg="red",
)
exit(1)
sys.exit(1)
except Exception:
click.secho(
"Invalid DSNs found in the config file. "
'Please check the "[alias_dsn]" section in pgclirc.',
err=True,
fg="red",
)
exit(1)
sys.exit(1)
pgcli.connect_uri(dsn_config)
pgcli.dsn_alias = dsn
elif "://" in database:
Expand Down
Loading