Last active
March 22, 2016 16:56
-
-
Save seffignoz/f6b55b4fbe5dd7520e37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
# -*- coding: UTF-8 -*- | |
# | |
# (c) Roberto Gambuzzi | |
# Created: 14/02/2011 15.41.12 | |
# Modified: 04/03/2011 20.25.50 | |
# | |
# v 0.0.1.0 | |
# | |
# file: mailmetheerror.py | |
# auth: Roberto Gambuzzi <[email protected]> | |
# desc: | |
# | |
# $Id: mailmetheerror.py 04/03/2011 20.25.50 roberto $ | |
# -------------- | |
import sys | |
import traceback | |
FROM = '[email protected]' | |
TO = '[email protected]' | |
SMTP = 'smtp.tin.com' | |
def mail(sb, text): | |
try: | |
import smtplib | |
from email.MIMEText import MIMEText | |
msg = MIMEText(text) | |
msg['From'] = FROM | |
msg['To'] = TO | |
msg['Subject'] = 'Error from '+sb | |
s = smtplib.SMTP() | |
s.connect(SMTP) | |
s.sendmail(FROM,TO, msg.as_string()) | |
s.close() | |
except: | |
pass | |
def install_excepthook(): | |
def my_excepthook(exctype, value, tb): | |
text = ''.join(traceback.format_exception(exctype, value, tb)) | |
mail(str(sys.argv[0]), text) | |
print text | |
sys.excepthook = my_excepthook | |
install_excepthook() | |
if __name__=="__main__": | |
mail(__file__,'Prova') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment