Skip to main content

auto emailer

Project description

Emailer

Emailer provides

a decorator to send emails on error instead of raise an error.

Usefull when

  1. Code should send out some kind of "alert" without breaking any code
  2. Complex error handling isn't needed or isn't a good choice cosidering cost/value

E.g. You are writing an script to do some ETL work for a report for your self or a small group It need to be reliable but good enough if you know it breaks and fix afterwards

Emails will be constructed as MIMEMultipart contains only simple text. And sent throught smtp wihtout any authentication, which suitsmost of internal smtp servers.

Installation

Install with pip

pip install error-emailer

Email construct

Email constructed as MIMEMultipart with default

error_msg_title = 'Error'

error_msg_content = 'Error occurred'

Example: Use decorator

from erroremailer import EmailError

ee = EmailError(
    from_addr = 'me@example.com',
    to_addr = 'others@example.com',
    smtp_addr = '10.0.0.1@some-smtp.com',
    # set send_email to False for test
    send_email_on_error = False,
    error_msg_title = 'Error occured in my best script"
    error_msg_content = 'Error occured in my best script"
    )

# define a function with deco
@ee.email_on_error()
def make_a_error():

    a = 1
    b = '2'
    print(a + b)

    return a

make_a_error()

Example: Use send email directly

from erroremailer import EmailError

ee = EmailError(
    from_addr = 'me@example.com',
    to_addr = 'others@example.com',
    smtp_addr = '10.0.0.1@some-smtp.com',
    # set send_email to False for test
    send_email_on_error = False,
    error_msg_title = 'Error occured in my best script"
    error_msg_content = 'Error occured in my best script"
    )

def make_a_error():

    a = 1
    b = '2'
    print(a + b)

    return a


if __name__ == '__main__':
    
    try:
        make_a_error()
    except:
        ee.send_error_email()
    finally:
        pass

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

error-emailer-0.1.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

error_emailer-0.1.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file error-emailer-0.1.2.tar.gz.

File metadata

  • Download URL: error-emailer-0.1.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.10

File hashes

Hashes for error-emailer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 151114f3f070ffd773343a7300fa487dff67461d1be9b66f496be3c997f5df13
MD5 3a9763bb7bef485d637c93a4c8d45c7f
BLAKE2b-256 04f1a97d1539d5b6ede8f00d96d6f24946ddabbed4db17faf6e2dfe7e178a61a

See more details on using hashes here.

File details

Details for the file error_emailer-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: error_emailer-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.10

File hashes

Hashes for error_emailer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 425d6750b77b6cf401dc0a6f456ec21fa7bce6c7dcb1a14a574a21e7e47b3802
MD5 cc82f784d3f94ea1bf555426476d852a
BLAKE2b-256 2da6266709c0c6d75305781ba130a65f54557047de31087b282e221c0bfaff07

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