aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod/pathoc.py
diff options
context:
space:
mode:
Diffstat (limited to 'libpathod/pathoc.py')
-rw-r--r--libpathod/pathoc.py40
1 files changed, 23 insertions, 17 deletions
diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py
index 40f698fd..0cc0466d 100644
--- a/libpathod/pathoc.py
+++ b/libpathod/pathoc.py
@@ -38,16 +38,17 @@ class Pathoc(tcp.TCPClient):
print >> fp, "%s (unprintables escaped):"%header
print >> fp, netlib.utils.cleanBin(data)
- def print_request(self, spec, showreq, showresp, explain, hexdump, fp=sys.stdout):
+ def print_request(self, spec, showreq, showresp, explain, hexdump, ignorecodes, fp=sys.stdout):
"""
Performs a series of requests, and prints results to the specified
file descriptor.
- reqs: A sequence of request specifications
+ spec: A request specification
showreq: Print requests
showresp: Print responses
explain: Print request explanation
hexdump: When printing requests or responses, use hex dump output
+ ignorecodes: Sequence of return codes to ignore
"""
try:
r = rparse.parse_request(self.settings, spec)
@@ -59,20 +60,11 @@ class Pathoc(tcp.TCPClient):
print >> fp, "File access error: %s"%v
return
- resp = None
+ resp, req = None, None
if showreq:
self.wfile.start_log()
try:
req = r.serve(self.wfile, None, self.host)
- if explain:
- print >> fp, ">> ", req["method"], repr(req["path"])
- for a in req["actions"]:
- print >> fp, "\t",
- for x in a:
- print >> fp, x,
- print >> fp
- if showreq:
- self._show(fp, ">> Request", self.wfile.get_log(), hexdump)
self.wfile.flush()
if showresp:
self.rfile.start_log()
@@ -83,8 +75,22 @@ class Pathoc(tcp.TCPClient):
print >> fp, "<<", "Timeout"
except tcp.NetLibDisconnect: # pragma: nocover
print >> fp, "<<", "Disconnect"
- if showresp:
- self._show(fp, "<< Response", self.rfile.get_log(), hexdump)
- else:
- if resp:
- self._show_summary(fp, *resp)
+
+ if req:
+ if ignorecodes and resp and resp[1] in ignorecodes:
+ return
+ if explain:
+ print >> fp, ">>", req["method"], repr(req["path"])
+ for a in req["actions"]:
+ print >> fp, "\t",
+ for x in a:
+ print >> fp, x,
+ print >> fp
+ if showreq:
+ self._show(fp, ">> Request", self.wfile.get_log(), hexdump)
+
+ if showresp:
+ self._show(fp, "<< Response", self.rfile.get_log(), hexdump)
+ else:
+ if resp:
+ self._show_summary(fp, *resp)