-
Notifications
You must be signed in to change notification settings - Fork 19
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
Test if database is open #5
Comments
Thanks for the report! Can you provide a minimal example?
…On 8 May 2019 10:50:26 CEST, Piegames ***@***.***> wrote:
I use a variation of the `test.py` script to retrieve some passwords.
But when the database is closed, it simply throws a generic
`keepassxc_browser.protocol.ProtocolError: Database not opened`
somewhere in the code.
I'd like to have the ability to cleanly check if the database is open
before starting to retrieve passwords (ideally without requiring
identification).
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#5
|
If I run it when the database is closed I'd like to add something like |
You can use try:
c.get_database_hash(id)
except ProtocolError as ex:
print(ex) # "Database not opened"
exit(1) |
Hm, I commented the database hash part out because when I run this and the database is open, I get
Don't know if this is related. |
Hm, I haven't seen that error before. Even if the access key hasn't been associated to the database we should be able to read the response to this request. What version of KeePassXC are you using? |
|
Ah, you're using a much newer version of KeePassXC than I am. Perhaps the interface has changed... It looks like that error message actually means KeePassXC couldn't decrypt the message we had sent, not that we couldn't read its response. As a workaround, you can also put the if not c.test_associate(id):
try:
associated_name = c.associate(id)
except ProtocolError as ex:
print(ex)
exit(1) |
I think
solves my issue, but I'd be happy to have a convenience method to do this for me. |
I cannot import
My code:
|
Ah, right, from keepassxc_browser.protocol import ProtocolError |
It works now as expected, thanks. |
I use a variation of the
test.py
script to retrieve some passwords. But when the database is closed, it simply throws a generickeepassxc_browser.protocol.ProtocolError: Database not opened
somewhere in the code.I'd like to have the ability to cleanly check if the database is open before starting to retrieve passwords (ideally without requiring identification).
The text was updated successfully, but these errors were encountered: