Changeset 598


Ignore:
Timestamp:
Jun 13, 2008, 2:32:32 AM (16 years ago)
Author:
price
Message:

send mail on non-CodeError? exceptions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-www/code/main.py

    r588 r598  
    580580    return templates.unauth(searchList=[{'simple' : True}])
    581581
     582def throwError(_, __, ___):
     583    """Throw an error, to test the error-tracing mechanisms."""
     584    raise RuntimeError("This is a test of the emergency broadcast system.")
     585
    582586mapping = dict(list=listVms,
    583587               vnc=vnc,
     
    587591               create=create,
    588592               help=helpHandler,
    589                unauth=unauthFront)
     593               unauth=unauthFront,
     594               errortest=throwError)
    590595
    591596def printHeaders(headers):
     
    595600    print
    596601
     602def send_error_mail(subject, body):
     603    import subprocess
     604
     605    to = 'xvm@mit.edu'
     606    mail = """To: %s
     607From: root@xvm.mit.edu
     608Subject: %s
     609
     610%s
     611""" % (to, subject, body)
     612    p = subprocess.Popen(['/usr/sbin/sendmail', to], stdin=subprocess.PIPE)
     613    p.stdin.write(mail)
     614    p.stdin.close()
     615    p.wait()
    597616
    598617def getUser(environ):
     
    669688            self.start('500 Internal Server Error', [('Content-Type', 'text/plain')])
    670689            import traceback
    671             yield '''Uh-oh!  We experienced an error.'
    672 Please email xvm-dev@mit.edu with the contents of this page.'
     690            send_error_mail('xvm error: %s' % (err,),
     691                            '%s\n' % (traceback.format_exc(),))
     692            yield '''Uh-oh!  We experienced an error.
     693Sorry about that.  We've gotten mail about it.
     694
     695Feel free to poke us at xvm@mit.edu if this bug is
     696consistently biting you and we don't seem to be fixing it.
     697
     698In case you're curious, the gory details are here.
    673699----
    674700%s
Note: See TracChangeset for help on using the changeset viewer.