18 from os import environ as env |
18 from os import environ as env |
19 from time import ctime, gmtime, localtime, strftime, time |
19 from time import ctime, gmtime, localtime, strftime, time |
20 |
20 |
21 error_page = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" |
21 error_page = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" |
22 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
22 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
23 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> |
23 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
24 <head> |
24 <head> |
25 <title>Internal Server Error</title> |
25 <title>Internal Server Error</title> |
26 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
26 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
27 </head> |
27 </head> |
28 <body> |
28 <body> |
29 <h1>Internal Server Error</h1> |
29 <h1>Internal Server Error</h1> |
30 <p>So wie es aussieht, ging bei der Bearbeitung Ihrer Anfrage etwas |
30 <p>The server encountered an internal error and was unable to complete your |
31 schief.</p> |
31 request.</p> |
32 <p>Sofern Sie den Fehler verursacht haben, dürfen Sie jetzt ein schlechtes |
32 <p>The administration team will take care of this problem. We apologize |
33 Gewissen haben.<br /> |
33 for any inconvenience.</p> |
34 Die Administration wird sich bei nächster Gelegenheit um das Problem |
|
35 kümmern. Bitte haben Sie dafür etwas Verständnis.</p> |
|
36 <h2>Error 500</h2> |
34 <h2>Error 500</h2> |
37 <p>Sorry</p> |
35 <p>Server got itself in trouble</p> |
38 </body> |
36 </body> |
39 </html>""" |
37 </html>""" |
|
38 error_page_is_xhtml = True |
40 msg_body = """Hi, |
39 msg_body = """Hi, |
41 |
40 |
42 an uncaught exception has occurred. The details are as follows: |
41 an uncaught exception has occurred. The details are as follows: |
43 |
42 |
44 Type: %(extype)s |
43 Type: %(extype)s |
116 write('Content-Type: application/xhtml+xml; charset=utf-8\r\n') |
115 write('Content-Type: application/xhtml+xml; charset=utf-8\r\n') |
117 write('Status: %d %s\r\n\r\n' % (s, http_status[s])) |
116 write('Status: %d %s\r\n\r\n' % (s, http_status[s])) |
118 sys.stdout.flush() |
117 sys.stdout.flush() |
119 |
118 |
120 def send_error_page(): |
119 def send_error_page(): |
121 send_header(500, True) |
120 send_header(500, error_page_is_xhtml) |
122 print error_page |
121 sys.stdout.write(error_page) |
|
122 sys.stdout.flush() |
123 |
123 |
124 def send_mail(info): |
124 def send_mail(info): |
125 global config |
125 global config |
126 config['now'] = time() |
126 config['now'] = time() |
127 config['host'] = info['host'] if info['host'] != 'n/a' else 'localhost' |
127 config['host'] = info['host'] if info['host'] != 'n/a' else 'localhost' |