summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Finney <seanius@debian.org>2009-08-18 08:44:52 +0200
committerSean Finney <seanius@debian.org>2009-08-31 22:35:01 +0200
commitd77a60063e61f1748b43c3d7accb8c942402a2cd (patch)
treea082f157c44acbd4d1f4e7a878a8755c0992f997
parent997beb5ffd2117fc7ed20035fca0b31d5063f612 (diff)
downloadpatch-tracker-d77a60063e61f1748b43c3d7accb8c942402a2cd.tar.gz
allow for pagehandler args to be passed on cmdline
-rwxr-xr-xpagehandler.py42
1 files changed, 29 insertions, 13 deletions
diff --git a/pagehandler.py b/pagehandler.py
index 3933fce..995f95c 100755
--- a/pagehandler.py
+++ b/pagehandler.py
@@ -37,6 +37,13 @@ usage: %s [-hp]
-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:], "hp")
profiling = False
for o,v in opts:
@@ -46,16 +53,25 @@ usage: %s [-hp]
if o == "-p":
profiling = True
- 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.run("server.handle_request()", "profile.out")
- p = pstats.Stats("profile.out")
- p.strip_dirs().sort_stats('time').print_stats(20)
- except IOError, e:
- print "adsf: ",e
+ 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.run("server.handle_request()", "profile.out")
+ p = pstats.Stats("profile.out")
+ p.strip_dirs().sort_stats('time').print_stats(20)
+ except IOError, e:
+ print "adsf: ",e
+ else:
+ os.environ['PATH_INFO'] = args[0]
+ if not profiling:
+ application(os.environ, cmdline_resp)
+ else:
+ profile.run("application(os.environ, cmdline_resp)", "profile.out")
+ p = pstats.Stats("profile.out")
+ p.strip_dirs().sort_stats('time').print_stats(20)