diff options
author | Sean Finney <seanius@debian.org> | 2011-03-30 19:18:19 +0200 |
---|---|---|
committer | Sean Finney <seanius@debian.org> | 2011-03-30 19:18:19 +0200 |
commit | dcbdefd119d43af6f8e11d97812ebd1942e1b8e8 (patch) | |
tree | 5f1d8151344c3d989c06ea8bf46a33ff1355876b | |
parent | d95eff9479b23d1349dcbd97deb7692768c742e4 (diff) | |
download | patch-tracker-dcbdefd119d43af6f8e11d97812ebd1942e1b8e8.tar.gz |
Remove old non-django pagehandler.py
-rwxr-xr-x | pagehandler.py | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/pagehandler.py b/pagehandler.py deleted file mode 100755 index 99379db..0000000 --- a/pagehandler.py +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# main (wsgi) request handler for patch-tracking system -# this handler file basically farms out all its work to the ReqHandler -# module, which in turn splits up the request URI and acts accordingly. - -import os -import sys - -def application(env, resp): - # everything is currently run relative to the pagehandler script. - whereami = os.path.dirname(env['SCRIPT_FILENAME']) - sys.path+=[whereami] - os.chdir(whereami) - - import patchtracker.ReqHandler as ReqHandler - try: - cmdh = ReqHandler.CmdHandler(env) - resp(cmdh.status, cmdh.headers) - return cmdh.output() - except ReqHandler.ReqHandlerException, e: - resp(e.status, [('Content-Type', 'text/html')]) - return ReqHandler.ErrorCmd(str(e), e.status).output() - -def profile_app(call): - import cProfile as profile, pstats - profile.run(call, "profile.out") - p = pstats.Stats("profile.out") - p.sort_stats('time', 'cumulative') - p.print_stats() - p.print_callers() - p.print_callees() - -if __name__ == '__main__': - os.environ['SCRIPT_FILENAME'] = sys.argv[0] - from wsgiref import simple_server as ss - import getopt - - def cmd_help(): - print """ -usage: %s [-hp] - - -h: help message - -p: enable profiling -"""%(os.path.basename(sys.argv[0])) - - def cmdline_resp(status, headers): - print "STATUS:",status - print "HEADERS START" - for h,v in headers: - print "%s: %s"%(h,v) - print - - opts,args = getopt.getopt(sys.argv[1:], "ho:p") - profiling = False - interactive_ofile = sys.stdout - for o,v in opts: - if o == "-h": - cmd_help() - sys.exit(0) - if o == "-p": - profiling = True - if o == "-o": - interactive_ofile = file(v, "w") - - if not args: - print "pagehandler test server running..." - server = ss.WSGIServer( ('',8080), ss.WSGIRequestHandler) - server.set_app(application) - while True: - try: - if not profiling: - server.handle_request() - else: - profile_app("server.handle_request()") - except IOError, e: - print "adsf: ",e - else: - os.environ['PATH_INFO'] = args[0] - if not profiling: - interactive_ofile.write(application(os.environ, cmdline_resp)) - else: - profile_app("interactive_ofile.write(application(os.environ, cmdline_resp))") - |