Be nice to your spouse (or other person who needs to run your scripts) - give your command line scripts some GUI feedback when needed.
Free software: ISC license
Documentation: https://bitbucket.org/spookylukey/spousefriendly
Motivation
Developers usually like to run scripts from a terminal. In addition, for these kind of Python scripts, if something goes wrong, the easiest thing to do is let it fail ‘ungracefully’, at which point you get a helpful stacktrace on the screen. And if it goes well, it should just exit without printing anything.
For your spouse or friend who just wants to double click an icon, both these behaviours will be very confusing. They normally want confirmation that it worked and is finished, and if it doesn’t it should show some kind of nice error message.
This package provides some simple wrappers (normally context managers) so that you can get the best of both worlds.
Basic usage
Take a typical script:
def main():
# Stuff here
if __name__ == '__main__':
main()
Simply wrap the call to main in a spousefriendly.friendly_success_and_failure with block:
import spousefriendly
if __name__ == '__main__':
with spousefriendly.friendly_success_and_failure():
main()
If running from a terminal, there will be no change in behaviour. From a GUI, however (e.g. launched from a file manager), upon exit there will be a success message, or a failure message if appropriate.
Detailed usage
friendly_success_and_failure composes two context managers:
spousefriendly.friendly_success(success_message='Optional success message') spousefriendly.friendly_failure(failure_message='Optional failure message')
Both success_message and failure_message can also be passed to friendly_success_and_failure as keyword arguments. Sensible defaults are used if not supplied.
Limitations
Obviously, the context managers can’t protect against anything that happens outside their scope (e.g. import errors etc.).
TODO
Windows support! This is the most obvious one. Since I don’t use Windows, I’m not in a position to test this. I’ve put some rudimentary things in, but it probably doesn’t work.
History
0.1.0 (2015-01-11)
First release on PyPI.
Metadata
Release files for spousefriendly 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spousefriendly-0.1.0.tar.gz | 6.7 kB | Without provenance | Details for spousefriendly-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spousefriendly-0.1.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for spousefriendly-0.1.0-py2.py3-none-any.whl |
Total release size: 12.5 kB
Release files / spousefriendly-0.1.0.tar.gz
| Download URL | spousefriendly-0.1.0.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0c6dd31b4b8613d092564bc06499d12588df69957a140a737f9fa8c958e6aa01
|
|
BLAKE2b-256 checksum How to use checksums |
43c95162102859e865c578748e3425b49bf6d5a37ed4a4431badd7f60be914e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / spousefriendly-0.1.0-py2.py3-none-any.whl
| Download URL | spousefriendly-0.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
1309dfa01a38d1a07a80ebc541ba2d4131b5639c9811ad818026def85b290076
|
|
BLAKE2b-256 checksum How to use checksums |
3ded249eeb6410588704dea46cb761047f9c86478cfd5ef2e7e617a22c4d62fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for spousefriendly 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.