[BangPypers] catching exceptions from SimpleHTTPServer
Rahul R
rahul8590 at gmail.com
Tue Jul 20 20:15:30 CEST 2010
>
> --------------------------------------------
> --- browser.py 2010-07-20 22:51:33.000000000 +0530
> +++ browser-new.py 2010-07-20 22:55:20.000000000 +0530
> @@ -18,4 +18,10 @@
>
> sa = httpd.socket.getsockname()
> print "Serving HTTP on", sa[0], "port", sa[1], "..."
> -httpd.serve_forever()
> +import sys
> +out = open("browser.log", "w")
> +sys.stderr = out
> +try:
> + httpd.serve_forever()
> +except:
> + out.close()
> --------------------------------------------
>
>
> negative aint working , i tried a few changes myself . when i referred to
the class BaseHTTPServer s methods ( http://bit.ly/aYqnQE ) i found a
particular method log_message which is similar to sys.stderr but for some
reason it isnt appending ne data into the log file created.
the revised code snippet:
http://codepad.org/PRPXVUpY
--Rahul
More information about the BangPypers
mailing list