Skip to content

Commit

Permalink
Silence pyflakes
Browse files Browse the repository at this point in the history
And pick up one bug as a consequence.
  • Loading branch information
cortesi committed Jan 19, 2014
1 parent cabd848 commit 7ddc941
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 20 deletions.
2 changes: 0 additions & 2 deletions libmproxy/cmdline.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import proxy
import re, filt
import argparse
import shlex
import os

APP_HOST = "mitm"
APP_PORT = 80
Expand Down
2 changes: 1 addition & 1 deletion libmproxy/console/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import mailcap, mimetypes, tempfile, os, subprocess, glob, time, shlex, stat
import os.path, sys, weakref
import urwid
from .. import controller, utils, flow
from .. import controller, utils, flow, script
import flowlist, flowview, help, common, grideditor, palettes, contentview, flowdetailview

EVENTLOG_SIZE = 500
Expand Down
2 changes: 1 addition & 1 deletion libmproxy/console/contentview.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def get_content_view(viewmode, hdrItems, content, limit, logfunc):
try:
ret = viewmode(hdrs, content, limit)
# Third-party viewers can fail in unexpected ways...
except Exception, e:
except Exception:
s = traceback.format_exc()
s = "Content viewer failed: \n" + s
logfunc(s)
Expand Down
2 changes: 1 addition & 1 deletion libmproxy/filt.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def _make():
def parse(s):
try:
return bnf.parseString(s, parseAll=True)[0]
except pp.ParseException, v:
except pp.ParseException:
return None
except ValueError:
return None
Expand Down
8 changes: 4 additions & 4 deletions libmproxy/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This module provides more sophisticated flow tracking. These match requests
with their responses, and provide filtering and interception facilities.
"""
import hashlib, Cookie, cookielib, copy, re, urlparse, os, threading
import hashlib, Cookie, cookielib, copy, re, urlparse, threading
import time, urllib
import tnetstring, filt, script, utils, encoding, proxy
from email.utils import parsedate_tz, formatdate, mktime_tz
Expand Down Expand Up @@ -1395,9 +1395,9 @@ def add_event(self, e, level="info"):
pass

def unload_scripts(self):
for script in self.scripts[:]:
script.unload()
self.scripts.remove(script)
for s in self.scripts[:]:
s.unload()
self.scripts.remove(s)

def load_script(self, command):
"""
Expand Down
2 changes: 1 addition & 1 deletion libmproxy/platform/linux.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import socket, struct, fcntl
import socket, struct

# Python socket module does not have this constant
SO_ORIGINAL_DST = 80
Expand Down
15 changes: 6 additions & 9 deletions libmproxy/proxy.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import sys, os, string, socket, time
import shutil, tempfile, threading
import SocketServer
import os, socket, time
import threading
from OpenSSL import SSL
from netlib import odict, tcp, http, certutils, http_status, http_auth
from netlib import tcp, http, certutils, http_status, http_auth
import utils, flow, version, platform, controller


Expand Down Expand Up @@ -91,7 +90,6 @@ def run(self):
server = ServerConnection(self.config, r.scheme, r.host, r.port, r.host)
server.connect()
server.send(r)
tsstart = utils.timestamp()
httpversion, code, msg, headers, content = http.read_response(
server.rfile, r.method, self.config.body_size_limit
)
Expand Down Expand Up @@ -123,7 +121,7 @@ def __call__(self, client_connection):
self.handler.sni = sn.decode("utf8").encode("idna")
# An unhandled exception in this method will core dump PyOpenSSL, so
# make dang sure it doesn't happen.
except Exception, e: # pragma: no cover
except Exception: # pragma: no cover
pass


Expand Down Expand Up @@ -240,7 +238,6 @@ def handle_request(self, cc):
request.ssl_setup_timestamp = sc.ssl_setup_timestamp
sc.rfile.reset_timestamps()
try:
tsstart = utils.timestamp()
peername = sc.connection.getpeername()
if peername:
request.ip = peername[0]
Expand All @@ -249,13 +246,13 @@ def handle_request(self, cc):
request.method,
self.config.body_size_limit
)
except http.HttpErrorConnClosed, v:
except http.HttpErrorConnClosed:
self.del_server_connection()
if sc.requestcount > 1:
continue
else:
raise
except http.HttpError, v:
except http.HttpError:
raise ProxyError(502, "Invalid server response.")
else:
break
Expand Down
2 changes: 1 addition & 1 deletion libmproxy/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os, datetime, urlparse, string, urllib, re
import os, datetime, urllib, re
import time, functools, cgi
import json
from netlib import http
Expand Down

0 comments on commit 7ddc941

Please sign in to comment.