aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmproxy/console.py20
-rw-r--r--libmproxy/flow.py2
-rw-r--r--libmproxy/proxy.py4
-rw-r--r--libmproxy/script.py5
-rw-r--r--libmproxy/utils.py2
-rw-r--r--test/serv.py2
-rw-r--r--test/sslserv.py2
-rw-r--r--test/test_dump.py5
-rw-r--r--test/test_encoding.py1
-rw-r--r--test/test_flow.py10
-rw-r--r--test/test_netstring.py4
-rw-r--r--test/test_proxy.py3
-rw-r--r--test/test_utils.py2
13 files changed, 23 insertions, 39 deletions
diff --git a/libmproxy/console.py b/libmproxy/console.py
index c798cf43..a16837a3 100644
--- a/libmproxy/console.py
+++ b/libmproxy/console.py
@@ -864,8 +864,6 @@ class Options(object):
"limit",
"no_server",
"refresh_server_playback",
- "request_script",
- "response_script",
"rfile",
"script",
"rheaders",
@@ -952,11 +950,6 @@ class ConsoleMaster(flow.FlowMaster):
self.conn_list_view = None
self.set_palette()
- if options.response_script:
- self.set_response_script(options.response_script)
- if options.request_script:
- self.set_request_script(options.request_script)
-
r = self.set_limit(options.limit)
if r:
print >> sys.stderr, "Limit error:", r
@@ -1085,15 +1078,14 @@ class ConsoleMaster(flow.FlowMaster):
return txt
def _view_conn_urlencoded(self, lines):
+ kv = format_keyvals(
+ [(k+":", v) for (k, v) in lines],
+ key = "header",
+ val = "text"
+ )
return [
urwid.Text(("highlight", "URLencoded data:\n")),
- urwid.Text(
- format_keyvals(
- [(k+":", v) for (k, v) in lines],
- key = "header",
- val = "text"
- )
- )
+ urwid.Text(kv)
]
def _find_pretty_view(self, content, hdrItems):
diff --git a/libmproxy/flow.py b/libmproxy/flow.py
index e649fbb8..89a91e68 100644
--- a/libmproxy/flow.py
+++ b/libmproxy/flow.py
@@ -2,7 +2,7 @@
This module provides more sophisticated flow tracking. These match requests
with their responses, and provide filtering and interception facilities.
"""
-import subprocess, sys, json, hashlib, Cookie, cookielib, base64, copy, re
+import json, hashlib, Cookie, cookielib, base64, copy, re
import time
import netstring, filt, script, utils, encoding, proxy
from email.utils import parsedate_tz, formatdate, mktime_tz
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py
index e95b38e2..0ef5e225 100644
--- a/libmproxy/proxy.py
+++ b/libmproxy/proxy.py
@@ -5,10 +5,10 @@
Development started from Neil Schemenauer's munchy.py
"""
-import sys, os, string, socket, select, time, Cookie
+import sys, os, string, socket, select, time
import shutil, tempfile, threading
import optparse, SocketServer, ssl
-import utils, controller, flow
+import utils, flow
NAME = "mitmproxy"
diff --git a/libmproxy/script.py b/libmproxy/script.py
index 251d6dea..bec07343 100644
--- a/libmproxy/script.py
+++ b/libmproxy/script.py
@@ -1,4 +1,4 @@
-import imp, os, traceback, flow
+import os, traceback
class ScriptError(Exception):
pass
@@ -14,7 +14,6 @@ class Script:
"""
def __init__(self, path, ctx):
self.path, self.ctx = path, ctx
- self.mod = None
self.ns = None
def load(self):
@@ -31,7 +30,7 @@ class Script:
raise ScriptError("Not a file: %s"%self.path)
ns = {}
try:
- self.mod = execfile(path, ns, ns)
+ execfile(path, ns, ns)
except Exception, v:
raise ScriptError(traceback.format_exc(v))
self.ns = ns
diff --git a/libmproxy/utils.py b/libmproxy/utils.py
index c9a8fd29..1c34b2fb 100644
--- a/libmproxy/utils.py
+++ b/libmproxy/utils.py
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re, os, subprocess, datetime, urlparse, string
-import time, functools, copy, cgi, textwrap
+import time, functools, cgi, textwrap
import json
CERT_SLEEP_TIME = 1
diff --git a/test/serv.py b/test/serv.py
index 9e43c08f..53747f08 100644
--- a/test/serv.py
+++ b/test/serv.py
@@ -1,4 +1,4 @@
-import socket, os, cStringIO, tempfile
+import socket
from SocketServer import BaseServer
from BaseHTTPServer import HTTPServer
import handler
diff --git a/test/sslserv.py b/test/sslserv.py
index 5153d0da..4aa4df39 100644
--- a/test/sslserv.py
+++ b/test/sslserv.py
@@ -1,4 +1,4 @@
-import socket, os, cStringIO, tempfile
+import socket
from SocketServer import BaseServer
from BaseHTTPServer import HTTPServer
import ssl
diff --git a/test/test_dump.py b/test/test_dump.py
index 808b3a7e..c5efed62 100644
--- a/test/test_dump.py
+++ b/test/test_dump.py
@@ -70,7 +70,6 @@ class uDumpMaster(libpry.AutoTree):
m = dump.DumpMaster(None, o, None, outfile=cs)
def test_read(self):
- cs = StringIO()
t = self.tmpdir()
p = os.path.join(t, "read")
self._flowfile(p)
@@ -130,10 +129,10 @@ class uDumpMaster(libpry.AutoTree):
)
def test_stickycookie(self):
- ret = self._dummy_cycle(1, None, "", stickycookie = ".*")
+ self._dummy_cycle(1, None, "", stickycookie = ".*")
def test_stickyauth(self):
- ret = self._dummy_cycle(1, None, "", stickyauth = ".*")
+ self._dummy_cycle(1, None, "", stickyauth = ".*")
diff --git a/test/test_encoding.py b/test/test_encoding.py
index d9e6a85c..fe338da1 100644
--- a/test/test_encoding.py
+++ b/test/test_encoding.py
@@ -2,7 +2,6 @@ from libmproxy import encoding
import libpry
import cStringIO
-import gzip, zlib
class uidentity(libpry.AutoTree):
def test_simple(self):
diff --git a/test/test_flow.py b/test/test_flow.py
index fa49aecd..85355b73 100644
--- a/test/test_flow.py
+++ b/test/test_flow.py
@@ -241,7 +241,6 @@ class uFlow(libpry.AutoTree):
class uState(libpry.AutoTree):
def test_backup(self):
- bc = flow.ClientConnect(("address", 22))
c = flow.State()
req = tutils.treq()
f = c.add_request(req)
@@ -285,10 +284,8 @@ class uState(libpry.AutoTree):
assert c.add_response(resp)
assert c.active_flow_count() == 0
- dc = flow.ClientDisconnect(bc)
def test_err(self):
- bc = flow.ClientConnect(("address", 22))
c = flow.State()
req = tutils.treq()
f = c.add_request(req)
@@ -305,7 +302,7 @@ class uState(libpry.AutoTree):
req = tutils.treq()
assert len(c.view) == 0
- f = c.add_request(req)
+ c.add_request(req)
assert len(c.view) == 1
c.set_limit("~s")
@@ -342,7 +339,7 @@ class uState(libpry.AutoTree):
def _add_response(self, state):
req = tutils.treq()
- f = state.add_request(req)
+ state.add_request(req)
resp = tutils.tresp(req)
state.add_response(resp)
@@ -539,7 +536,7 @@ class uFlowMaster(libpry.AutoTree):
tf = tutils.tflow_full()
tf.response.headers["set-cookie"] = ["foo=bar"]
fm.handle_request(tf.request)
- f = fm.handle_response(tf.response)
+ fm.handle_response(tf.response)
assert fm.stickycookie_state.jar
assert not "cookie" in tf.request.headers
fm.handle_request(tf.request)
@@ -690,7 +687,6 @@ class uResponse(libpry.AutoTree):
h = flow.Headers()
h["test"] = ["test"]
c = flow.ClientConnect(("addr", 2222))
- r = flow.Request(c, "host", 22, "https", "GET", "/", h, "content")
req = flow.Request(c, "host", 22, "https", "GET", "/", h, "content")
resp = flow.Response(req, 200, "msg", h.copy(), "content")
diff --git a/test/test_netstring.py b/test/test_netstring.py
index 3c56acd9..5c4f775a 100644
--- a/test/test_netstring.py
+++ b/test/test_netstring.py
@@ -9,10 +9,10 @@ class uNetstring(libpry.AutoTree):
self.encoded_data = "9:Netstring,6:module,2:by,4:Will,7:McGugan,"
def test_header(self):
- tests = [ ("netstring", "9:"),
+ t = [ ("netstring", "9:"),
("Will McGugan", "12:"),
("", "0:") ]
- for test, result in tests:
+ for test, result in t:
assert netstring.header(test) == result
def test_file_encoder(self):
diff --git a/test/test_proxy.py b/test/test_proxy.py
index bb86a6ba..16b6034c 100644
--- a/test/test_proxy.py
+++ b/test/test_proxy.py
@@ -1,7 +1,6 @@
-import cStringIO, time, re
+import cStringIO, time
import libpry
from libmproxy import proxy, controller, utils, dump
-import tutils
class u_read_chunked(libpry.AutoTree):
diff --git a/test/test_utils.py b/test/test_utils.py
index b38c96c1..8b16e057 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -40,7 +40,7 @@ class upretty_size(libpry.AutoTree):
def test_simple(self):
assert utils.pretty_size(100) == "100B"
assert utils.pretty_size(1024) == "1kB"
- assert utils.pretty_size(1024 + (1024/2)) == "1.5kB"
+ assert utils.pretty_size(1024 + (1024/2.0)) == "1.5kB"
assert utils.pretty_size(1024*1024) == "1M"