PynEntry
A pythonic wrapper for pinentry
Written mostly to practice metaprogramming
credit to mijikai for a working example
Requires pinentry to be installed
convienience methods:
- to quickly and simply get a password/pin from a user:
get_pin(description=None, prompt=None, timeout=0, display=None, global_grab=True)
- to show and get a confirmation from a user:
get_confirm(description=None, timeout=0, display=None, global_grab=True)
- to show a message to a user:
show_message(description=None, timeout=0, display=None, global_grab=True)
PynEntry class
The above methods instance and configure a PynEntry instance wich can be called and configured manually via attributes
the PynEntry class supports the following attributes:
description: Sets the descriptive text to displayprompt: Sets the text just before the passphrase entry (ex: "PASS:")title: Sets the window titleok_text: Sets the text shown in the "OK" buttoncancel_text: Sets the text shown in the "Cancel" buttonerror_text: Sets the text in case of error before reprompt (Cleared after everyget_pin()call)tty_name: Chose the tty to use (set automatically)tty_type: Change the tty type to use.locale: Sets the locale to use (set automatically to current os locale)
NOTE: The PynEntry class uses the $PATH variable to find the pinentry executable, you can specify the location of the
executable manually when you initialize like so: PynEntry(executable='/path/to/pinentry')
PynEntry is best used as a context manager to automatically kill the pinentry process when you are done.
Example:
import pynentry
pynentry.show_message('Hello there!')
with pynentry.PynEntry() as p:
p.description = 'Enter a password.\n Choose Wisely!'
p.prompt = 'PASS>'
try:
passwd = p.get_pin()
except pynentry.PinEntryCancelled:
print('Cancelled?! Goodbye.')
exit()
p.ok_text = 'yep!'
p.cancel_text = 'nope!'
p.description = f'CAN YOU CONFIRM YOUR SUPER SECRET PASSWORD IS {passwd}?'
if p.get_confirm():
print(f'password {passwd} saved!')
else:
print(f'Too bad, so sad')
Release files for pynentry 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pynentry-0.1.9-py3-none-any.whl | Python 3 | none | any | Details |
Release files / pynentry-0.1.9-py3-none-any.whl
| Download URL | pynentry-0.1.9-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c1c782cc5a69ab89c5fcd21c4ebd465b9ccf8bef269bef02c0226ce19b2ddea
|
|
BLAKE2b-256 checksum How to use checksums |
fa934a4647dfac8f280b4b140ec0a4c2c2a8cdc7d2f6200ee8743a1ae082b6e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|