Mercurial > code > home > repos > homeauto
annotate lib/cycloneerr.py @ 1291:c1b0813372cc
move to /my/proj/hardware/busyboxArduino. hardware is still around and this has notes on how to use it.
Ignore-this: 7743f57abef17980c595b1686abf646a
darcs-hash:75f747175229c26222b107b64458d0c01845e17d
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sun, 21 Apr 2019 01:26:58 -0700 |
parents | 202edadf4351 |
children |
rev | line source |
---|---|
1233 | 1 try: |
1275 | 2 import http.client as httplib |
1233 | 3 except ImportError: |
1275 | 4 import httplib # type: ignore |
1233 | 5 import cgi |
809
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
6 |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
7 class PrettyErrorHandler(object): |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
8 """ |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
9 mix-in to improve cyclone.web.RequestHandler |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
10 """ |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
11 def get_error_html(self, status_code, **kwargs): |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
12 try: |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
13 tb = kwargs['exception'].getTraceback() |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
14 except AttributeError: |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
15 tb = "" |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
16 return "<html><title>%(code)d: %(message)s</title>" \ |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
17 "<body>%(code)d: %(message)s<pre>%(tb)s</pre></body></html>" % { |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
18 "code": status_code, |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
19 "message": httplib.responses[status_code], |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
20 "tb" : cgi.escape(tb), |
bebb8f7c5a3e
move a bunch of services into this tree, give them all web status pages
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
21 } |