diff options
author | Wayne Cheng <waynethecheng@gmail.com> | 2019-12-03 22:50:29 -0500 |
---|---|---|
committer | Wayne Cheng <waynethecheng@gmail.com> | 2019-12-03 22:50:29 -0500 |
commit | 423f7aadf6ab0636715cd7991aba3f8ff0da04a5 (patch) | |
tree | 2a3525355911cd6644df94f331431c8d4a143da7 | |
parent | a817834919714716e8075859d842ee15995d17f6 (diff) | |
download | qutebrowser-423f7aadf6ab0636715cd7991aba3f8ff0da04a5.tar.gz qutebrowser-423f7aadf6ab0636715cd7991aba3f8ff0da04a5.zip |
#5130 - LastPass CLI errors that aren't lookup failures should terminate lookup loop
-rwxr-xr-x | misc/userscripts/qute-lastpass | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/misc/userscripts/qute-lastpass b/misc/userscripts/qute-lastpass index ea88cf86f..6845a4cda 100755 --- a/misc/userscripts/qute-lastpass +++ b/misc/userscripts/qute-lastpass @@ -19,7 +19,7 @@ # along with qutebrowser. If not, see <http://www.gnu.org/licenses/>. """ -Insert login information using lastpass CLI and a dmenu-compatible application (e.g. dmenu, rofi -dmenu, ...). +Insert login information using lastpass CLI and a dmenu-compatible application (e.g. dmenu, rofi -dmenu, ...). A short demonstration can be seen here: https://i.imgur.com/zA61NrF.gifv. """ @@ -85,15 +85,12 @@ def pass_(domain, encoding): args = ['lpass', 'show', '-x', '-j', '-G', '.*{:s}.*'.format(domain)] process = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + candidates = json.loads(process.stdout.decode(encoding).strip() or '[]') err = process.stderr.decode(encoding).strip() - if err: - msg = "LastPass CLI returned for {:s} - {:s}".format(domain, err) - stderr(msg) - return '[]' + if 'could not find specified account' in err.lower(): + return candidates, '' - out = process.stdout.decode(encoding).strip() - - return out + return candidates, err def dmenu(items, invocation, encoding): command = shlex.split(invocation) @@ -121,7 +118,11 @@ def main(arguments): # the URL represents candidates = [] for target in filter(None, [extract_result.fqdn, extract_result.registered_domain, extract_result.subdomain + extract_result.domain, extract_result.domain, extract_result.ipv4]): - target_candidates = json.loads(pass_(target, arguments.io_encoding)) + target_candidates, err = pass_(target, arguments.io_encoding) + if err: + stderr("LastPass CLI returned for {:s} - {:s}".format(target, err)) + return ExitCodes.FAILURE + if not target_candidates: continue |