witten
/
luminotes
Archived
1
0
Fork 0

Now emailing tracebacks to support email address.

This commit is contained in:
Dan Helfman 2007-10-31 23:33:09 +00:00
parent bb9fff5e6f
commit f7de4c9e94
3 changed files with 33 additions and 3 deletions

View File

@ -22,7 +22,7 @@ settings = {
"luminotes.https_url": "",
"luminotes.http_proxy_ip": "127.0.0.1",
"luminotes.https_proxy_ip": "127.0.0.2",
"luminotes.support_email": "support@luminotes.com",
"luminotes.support_email": "",
"luminotes.rate_plans": [
{
"name": "basic",

View File

@ -55,9 +55,9 @@ def expose( view = None, rss = None ):
if hasattr( error, "to_dict" ):
result = error.to_dict()
else:
# TODO: it'd be nice to send an email to myself with the traceback
import traceback
traceback.print_exc()
cherrypy.root.report_traceback()
result = dict( error = u"An error occurred when processing your request. Please try again or contact support." )
redirect = result.get( u"redirect", None )

View File

@ -164,12 +164,42 @@ class Root( object ):
cherrypy.response.body = [ unicode( Not_found_page( support_email ) ) ]
return
# TODO: it'd be nice to send an email to myself with the traceback
import traceback
traceback.print_exc()
self.report_traceback()
cherrypy.response.body = [ unicode( Error_page( support_email ) ) ]
def report_traceback( self ):
"""
If a support email address is configured, send it an email with the current traceback.
"""
support_email = self.__settings[ u"global" ].get( u"luminotes.support_email" )
if not support_email: return False
import smtplib
import traceback
from email import Message
message = Message.Message()
message[ u"from" ] = support_email
message[ u"to" ] = support_email
message[ u"subject" ] = u"Luminotes traceback"
message.set_payload(
u"requested URL: %s\n" % cherrypy.request.browser_url +
u"user id: %s\n" % cherrypy.session.get( "user_id" ) +
u"username: %s\n\n" % cherrypy.session.get( "username" ) +
traceback.format_exc()
)
# send the message out through localhost's smtp server
server = smtplib.SMTP()
server.connect()
server.sendmail( message[ u"from" ], [ support_email ], message.as_string() )
server.quit()
return True
database = property( lambda self: self.__database )
notebooks = property( lambda self: self.__notebooks )
users = property( lambda self: self.__users )