if __name__ == '__main__':
import atexit
atexit.register(printError)
- sys.stderr = StringIO()
sys.path.append('/home/ecprice/.local/lib/python2.5/site-packages')
DEFAULT_HEADERS = {'Content-Type': 'text/html'}
-def error(op, username, fields, err, emsg):
+def error(op, username, fields, err, emsg, traceback):
"""Print an error page when a CodeError occurs"""
send_error_mail('xvm error on %s for %s: %s' % (op, username, err),
'error on %s for %s: %s\n\n%s\n'
% (op, username, err, emsg))
- d = dict(op=op, user=username, errorMessage=str(err),
- stderr=emsg)
+ d = dict(op=op, user=username, fields=fields,
+ errorMessage=str(err), stderr=emsg, traceback=traceback)
return templates.error(searchList=[d])
def invalidInput(op, username, fields, err, emsg):
self.state.environ = environ
def __iter__(self):
+ sys.stderr = StringIO()
fields = cgi.FieldStorage(fp=self.environ['wsgi.input'], environ=self.environ)
- print >> sys.stderr, fields
operation = self.environ.get('PATH_INFO', '')
if not operation:
self.start("301 Moved Permanently", [('Location',
output_string = str(output)
checkpoint.checkpoint('output as a string')
except Exception, err:
+ import traceback
if not fields.has_key('js'):
if isinstance(err, CodeError):
self.start('500 Internal Server Error', [('Content-Type', 'text/html')])
e = revertStandardError()
- s = error(operation, self.username, fields, err, e)
+ s = error(operation, self.username, fields,
+ err, e, traceback.format_exc())
yield str(s)
return
if isinstance(err, InvalidInput):
yield str(invalidInput(operation, self.username, fields, err, e))
return
self.start('500 Internal Server Error', [('Content-Type', 'text/plain')])
- import traceback
send_error_mail('xvm error: %s' % (err,),
'%s\n' % (traceback.format_exc(),))
yield '''Uh-oh! We experienced an error.