+def send_error_mail(subject, body):
+ import subprocess
+
+ to = config.web.errormail
+ mail = """To: %s
+From: root@%s
+Subject: %s
+
+%s
+""" % (to, config.web.hostname, subject, body)
+ p = subprocess.Popen(['/usr/sbin/sendmail', to], stdin=subprocess.PIPE)
+ p.stdin.write(mail)
+ p.stdin.close()
+ p.wait()
+
+def show_error(op, username, fields, err, emsg, traceback):
+ """Print an error page when an exception occurs"""
+ d = dict(op=op, user=username, fields=fields,
+ errorMessage=str(err), stderr=emsg, traceback=traceback)
+ details = templates.error_raw(searchList=[d])
+ exclude = config.web.errormail_exclude
+ if username not in exclude and '*' not in exclude:
+ send_error_mail('xvm error on %s for %s: %s' % (op, username, err),
+ details)
+ d['details'] = details
+ return templates.error(searchList=[d])