From e4045dc7f858e1e7d2368819e7ad251f4e1d7f90 Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Sat, 28 May 2016 22:25:54 +0200 Subject: pathod: fix most flake8 offenses --- pathod/language/http.py | 1 + pathod/language/http2.py | 7 +++---- pathod/pathoc.py | 3 +-- pathod/pathod.py | 1 - pathod/pathod_cmdline.py | 11 +++++------ pathod/protocols/http2.py | 1 + 6 files changed, 11 insertions(+), 13 deletions(-) (limited to 'pathod') diff --git a/pathod/language/http.py b/pathod/language/http.py index a82f12fe..b2308d5e 100644 --- a/pathod/language/http.py +++ b/pathod/language/http.py @@ -11,6 +11,7 @@ from . import base, exceptions, actions, message # instead of duplicating the HTTP on-the-wire representation here. # see http2 language for an example + class WS(base.CaselessLiteral): TOK = "ws" diff --git a/pathod/language/http2.py b/pathod/language/http2.py index d5e3ca31..85d9047f 100644 --- a/pathod/language/http2.py +++ b/pathod/language/http2.py @@ -27,6 +27,7 @@ from . import base, message h2f:42:DATA:END_STREAM,PADDED:0x1234567:'content body payload' """ + def get_header(val, headers): """ Header keys may be Values, so we have to "generate" them as we try the @@ -48,6 +49,7 @@ class _HeaderMixin(object): self.value.get_generator(settings), ) + class _HTTP2Message(message.Message): @property def actions(self): @@ -287,13 +289,10 @@ class Request(_HTTP2Message): def spec(self): return ":".join([i.spec() for i in self.tokens]) + def make_error_response(reason, body=None): tokens = [ StatusCode("800"), Body(base.TokValueLiteral("pathod error: " + (body or reason))), ] return Response(tokens) - - -# class Frame(message.Message): -# pass diff --git a/pathod/pathoc.py b/pathod/pathoc.py index 8706868b..910387b6 100644 --- a/pathod/pathoc.py +++ b/pathod/pathoc.py @@ -41,7 +41,7 @@ class SSLInfo(object): "Cipher: %s, %s bit, %s" % self.cipher, "SSL certificate chain:" ] - for n,i in enumerate(self.certchain): + for n, i in enumerate(self.certchain): parts.append(" Certificate [%s]" % n) parts.append("\tSubject: ") for cn in i.get_subject().get_components(): @@ -72,7 +72,6 @@ class SSLInfo(object): return "\n".join(parts) - class WebsocketFrameReader(threading.Thread): def __init__( diff --git a/pathod/pathod.py b/pathod/pathod.py index af5f9e6a..7795df0e 100644 --- a/pathod/pathod.py +++ b/pathod/pathod.py @@ -112,7 +112,6 @@ class PathodHandler(tcp.BaseHandler): return None, response_log return self.handle_http_request, response_log - def handle_http_request(self, logger): """ Returns a (handler, log) tuple. diff --git a/pathod/pathod_cmdline.py b/pathod/pathod_cmdline.py index 1f972a49..a7cd2495 100644 --- a/pathod/pathod_cmdline.py +++ b/pathod/pathod_cmdline.py @@ -49,12 +49,12 @@ def args_pathod(argv, stdout_=sys.stdout, stderr_=sys.stderr): help=""" URL path specifying prefix for URL crafting commands. (%s) - """%pathod.DEFAULT_CRAFT_ANCHOR + """ % pathod.DEFAULT_CRAFT_ANCHOR ) parser.add_argument( "--confdir", - action="store", type = str, dest="confdir", default='~/.mitmproxy', - help = "Configuration directory. (~/.mitmproxy)" + action="store", type=str, dest="confdir", default='~/.mitmproxy', + help="Configuration directory. (~/.mitmproxy)" ) parser.add_argument( "-d", dest='staticdir', default=None, type=str, @@ -117,8 +117,8 @@ def args_pathod(argv, stdout_=sys.stdout, stderr_=sys.stderr): ) group.add_argument( "--cert", dest='ssl_certs', default=[], type=str, - metavar = "SPEC", action="append", - help = """ + metavar="SPEC", action="append", + help=""" Add an SSL certificate. SPEC is of the form "[domain=]path". The domain may include a wildcard, and is equal to "*" if not specified. The file at path is a certificate in PEM format. If a private key is included in @@ -177,7 +177,6 @@ def args_pathod(argv, stdout_=sys.stdout, stderr_=sys.stderr): help="Output all received & sent HTTP/2 frames" ) - args = parser.parse_args(argv[1:]) args.ssl_version, args.ssl_options = tcp.sslversion_choices[args.ssl_version] diff --git a/pathod/protocols/http2.py b/pathod/protocols/http2.py index 688cc64e..3f45ec80 100644 --- a/pathod/protocols/http2.py +++ b/pathod/protocols/http2.py @@ -1,6 +1,7 @@ from netlib.http import http2 from .. import language + class HTTP2Protocol: def __init__(self, pathod_handler): -- cgit v1.2.3