summaryrefslogtreecommitdiffstats
path: root/pgcli
diff options
context:
space:
mode:
authorAmjith Ramanujam <amjith.r@gmail.com>2018-06-25 13:55:54 -0700
committerAmjith Ramanujam <amjith.r@gmail.com>2018-06-25 13:55:54 -0700
commit4c173fd01ff191477cdaf56b6969a1fb9a80eda8 (patch)
treee579bbc264aed45821c5e2d944dbbe63c534a4de /pgcli
parentd403189db7a216093473f9677da7608fc4e8bcb3 (diff)
Gurad against missing keyring backend.
Diffstat (limited to 'pgcli')
-rw-r--r--pgcli/main.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/pgcli/main.py b/pgcli/main.py
index f2903b7f..174cf688 100644
--- a/pgcli/main.py
+++ b/pgcli/main.py
@@ -412,7 +412,10 @@ class PGCli(object):
# Find password from store
key = '%s@%s' % (user, host)
if not passwd:
- passwd = keyring.get_password('pgcli', key)
+ try:
+ passwd = keyring.get_password('pgcli', key)
+ except RuntimeError:
+ pass
# Prompt for a password immediately if requested via the -W flag. This
# avoids wasting time trying to connect to the database and catching a
@@ -450,7 +453,10 @@ class PGCli(object):
dsn, application_name='pgcli',
**kwargs)
if passwd:
- keyring.set_password('pgcli', key, passwd)
+ try:
+ keyring.set_password('pgcli', key, passwd)
+ except (keyring.errors.InitError, RuntimeError):
+ pass
else:
raise e