diff options
author | Florian Bruhin <me@the-compiler.org> | 2019-12-23 15:41:15 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2019-12-23 15:41:15 +0100 |
commit | 5cdd1b99029e25fe69d2c0086a74b00120375ae9 (patch) | |
tree | eff47b562e713f811143533f5741e18ce8484b57 | |
parent | d93fef7d72e5b71f973e5b63d1034bc9e46f6242 (diff) | |
parent | 423f7aadf6ab0636715cd7991aba3f8ff0da04a5 (diff) | |
download | qutebrowser-5cdd1b99029e25fe69d2c0086a74b00120375ae9.tar.gz qutebrowser-5cdd1b99029e25fe69d2c0086a74b00120375ae9.zip |
Merge remote-tracking branch 'origin/pr/5134'
-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 |