diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py index 90f3b98bd..7551c589f 100644 --- a/libpathod/pathoc.py +++ b/libpathod/pathoc.py @@ -38,7 +38,7 @@ 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, ignorecodes, fp=sys.stdout): + def print_request(self, spec, showreq, showresp, explain, hexdump, ignorecodes, ignoretimeout, fp=sys.stdout): """ Performs a series of requests, and prints results to the specified file descriptor. @@ -74,6 +74,8 @@ class Pathoc(tcp.TCPClient): except http.HttpError, v: print >> fp, "<< HTTP Error:", v.msg except tcp.NetLibTimeout: + if ignoretimeout: + return print >> fp, "<<", "Timeout" except tcp.NetLibDisconnect: # pragma: nocover print >> fp, "<<", "Disconnect" diff --git a/pathoc b/pathoc index a2749a599..5932d4a45 100755 --- a/pathoc +++ b/pathoc @@ -35,7 +35,7 @@ if __name__ == "__main__": ) group = parser.add_argument_group('Controlling Output') group.add_argument( - "-c", dest="ignorecodes", type=str, default="", + "-C", dest="ignorecodes", type=str, default="", help="Comma-separated list of response codes to ignore" ) group.add_argument( @@ -54,6 +54,10 @@ if __name__ == "__main__": "-r", dest="showresp", action="store_true", default=False, help="Print full response" ) + group.add_argument( + "-T", dest="ignoretimeout", action="store_true", default=False, + help="Ignore timeouts" + ) group.add_argument( "-x", dest="hexdump", action="store_true", default=False, help="Output in hexdump format" @@ -94,7 +98,8 @@ if __name__ == "__main__": showresp=args.showresp, explain=args.explain, hexdump=args.hexdump, - ignorecodes=codes + ignorecodes=codes, + ignoretimeout=args.ignoretimeout ) sys.stdout.flush() if ret and args.oneshot: diff --git a/test/test_pathoc.py b/test/test_pathoc.py index e9690dd58..1c64f076f 100644 --- a/test/test_pathoc.py +++ b/test/test_pathoc.py @@ -24,7 +24,7 @@ class TestDaemon: _, _, _, _, content = c.request("get:/api/info") assert tuple(json.loads(content)["version"]) == version.IVERSION - def tval(self, requests, showreq=False, showresp=False, explain=False, hexdump=False, timeout=None, ignorecodes=None): + def tval(self, requests, showreq=False, showresp=False, explain=False, hexdump=False, timeout=None, ignorecodes=None, ignoretimeout=None): c = pathoc.Pathoc("127.0.0.1", self.d.port) c.connect() if timeout: @@ -38,6 +38,7 @@ class TestDaemon: explain = explain, hexdump = hexdump, ignorecodes = ignorecodes, + ignoretimeout = ignoretimeout, fp = s ) return s.getvalue()