Skip to main content

Simple, unobtrusive script exit notifications.

Project description

Farewell

Simple, unobtrusive script exit notifications.

Installation

pip install farewell

Quickstart

The farewell module is designed to be used in a script that eventually exits.

Basic usage

from farewell import on_exit

def on_success():
    print("✅ Everything worked!")

def on_error(error):
    print(f"❌ Failed: {error['type']} - {error['message']}")

on_exit(succes_func=on_success,
        error_func=on_error)

# You actual script logic below - completely unchanged!
print("Script running...")

# Uncomment to test error:
# raise ValueError("Test error!")

print("Script finished!")

Usage with a main()

from farewell import on_exit

def setup_notifications() :
    def success_notification():
        print("✅ Everything worked!")
    
    def error_notification(error):
        print(f"❌ Failed: {error['type']} - {error['message']}")

    on_exit(success_notification, error_notification)

def main():
    print("Script running...")
    
    # Uncomment to test error:
    # raise ValueError("Test error!")
    
    print("Script finished!")

if __name__ == "__main__":
    setup_notifications() # could also be called inside main()
    main()

Example with AWS SNS notifications

Also checkout ./examples/sns.py for a more complete example.

from farewell import on_exit
import boto3

sns = boto3.client('sns')

def notify_success():
    sns.publish(TopicArn="...", Message="✅ Everything worked!")

def notify_error(err):
    sns.publish(TopicArn="...", Message=f"❌ Failed: {err['type']} - {err['message']}")

on_exit(succes_func=notify_success,
        error_func=notify_error)

# You actual script logic below - completely unchanged!

next

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

farewell-0.1.0.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

farewell-0.1.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file farewell-0.1.0.tar.gz.

File metadata

  • Download URL: farewell-0.1.0.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for farewell-0.1.0.tar.gz
Algorithm Hash digest
SHA256 15a7462ae83c7297b4dac5b492317e88647f57f61199d39e602c67a082997a1b
MD5 6f42c157f5b449ee8e27dc562b16cd5c
BLAKE2b-256 91514c9144598db5748606c59a2645217124386a039f0ee8ee94d8934f950985

See more details on using hashes here.

File details

Details for the file farewell-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: farewell-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for farewell-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dbb26ed7eeab75ed43b653ebf68dc6c6a46c18514db7a1af0d490f2a18ab2b55
MD5 8e21d3f6708e7b90b3eee08e76033e40
BLAKE2b-256 ee4e603b50269bc19f67ee23a4c744ea85d386ebe0e6ab265b513c4ca4d24dfc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page