summaryrefslogtreecommitdiff
path: root/paste/debug
diff options
context:
space:
mode:
Diffstat (limited to 'paste/debug')
-rwxr-xr-xpaste/debug/debugapp.py2
-rwxr-xr-xpaste/debug/doctest_webapp.py13
-rw-r--r--paste/debug/fsdiff.py17
-rw-r--r--paste/debug/prints.py2
-rw-r--r--paste/debug/profile.py8
-rwxr-xr-xpaste/debug/testserver.py6
-rw-r--r--paste/debug/watchthreads.py8
-rw-r--r--paste/debug/wdg_validate.py5
8 files changed, 22 insertions, 39 deletions
diff --git a/paste/debug/debugapp.py b/paste/debug/debugapp.py
index 8c7c7c2..f752c36 100755
--- a/paste/debug/debugapp.py
+++ b/paste/debug/debugapp.py
@@ -17,7 +17,7 @@ class SimpleApplication(object):
Produces a simple web page
"""
def __call__(self, environ, start_response):
- body = "<html><body>simple</body></html>"
+ body = b"<html><body>simple</body></html>"
start_response("200 OK", [('Content-Type', 'text/html'),
('Content-Length', str(len(body)))])
return [body]
diff --git a/paste/debug/doctest_webapp.py b/paste/debug/doctest_webapp.py
index f399ac3..ffcfaa7 100755
--- a/paste/debug/doctest_webapp.py
+++ b/paste/debug/doctest_webapp.py
@@ -8,10 +8,7 @@
These are functions for use when doctest-testing a document.
"""
-try:
- import subprocess
-except ImportError:
- from paste.util import subprocess24 as subprocess
+import subprocess
import doctest
import os
import sys
@@ -214,7 +211,7 @@ def show_file(path, version, description=None, data=None):
data = f.read()
f.close()
if ext == '.py':
- html = ('<div class="source-code">%s</div>'
+ html = ('<div class="source-code">%s</div>'
% PySourceColor.str2html(data, PySourceColor.dark))
else:
html = '<pre class="source-code">%s</pre>' % cgi.escape(data, 1)
@@ -241,7 +238,7 @@ def write_data(path, data):
f = open(path, 'wb')
f.write(data)
f.close()
-
+
def change_file(path, changes):
f = open(os.path.abspath(path), 'rb')
@@ -282,7 +279,7 @@ class LongFormDocTestParser(doctest.DocTestParser):
(?![ ]*>>>) # Not a line starting with PS1
.*$\n? # But any other line
)*))
- |
+ |
(?: # This is for longer commands that are prefixed with a reST
# comment like '.. run:' (two colons makes that a directive).
# These commands cannot have any output.
@@ -331,7 +328,7 @@ class LongFormDocTestParser(doctest.DocTestParser):
# Get the example's indentation level.
runner = m.group('run') or ''
indent = len(m.group('%sindent' % runner))
-
+
# Divide source into lines; check that they're properly
# indented; and then strip their indentation & prompts.
source_lines = m.group('%ssource' % runner).split('\n')
diff --git a/paste/debug/fsdiff.py b/paste/debug/fsdiff.py
index 156a2e4..6f9ec2d 100644
--- a/paste/debug/fsdiff.py
+++ b/paste/debug/fsdiff.py
@@ -17,12 +17,8 @@ try:
# Python 3
import collections.UserDict as IterableUserDict
except ImportError:
- try:
- # Python 2.5-2.7
- from UserDict import IterableUserDict
- except ImportError:
- # Python <= 2.4
- from paste.util.UserDict24 import IterableUserDict
+ # Python 2.5-2.7
+ from UserDict import IterableUserDict
import operator
import re
@@ -131,13 +127,6 @@ class Snapshot(IterableUserDict):
return True
return False
- def _ignore_file(self, fn):
- if fn in self.ignore_paths:
- return True
- if self.ignore_hidden and os.path.basename(fn).startswith('.'):
- return True
- return False
-
def _find_traverse(self, path, result):
full = os.path.join(self.base_path, path)
if os.path.isdir(full):
@@ -298,7 +287,7 @@ class Dir(File):
"Directory %r doesn't have content" % self)
bytes = property(bytes__get)
-
+
def _space_prefix(pref, full, sep=None, indent=None, include_sep=True):
"""
diff --git a/paste/debug/prints.py b/paste/debug/prints.py
index 6cc3f7d..b660bfa 100644
--- a/paste/debug/prints.py
+++ b/paste/debug/prints.py
@@ -132,7 +132,7 @@ class PrintDebugMiddleware(object):
_body_re = re.compile(r'<body[^>]*>', re.I)
_explicit_re = re.compile(r'<pre\s*[^>]*id="paste-debug-prints".*?>',
re.I+re.S)
-
+
def add_log(self, html, log):
if not log:
return html
diff --git a/paste/debug/profile.py b/paste/debug/profile.py
index 036c805..470a54a 100644
--- a/paste/debug/profile.py
+++ b/paste/debug/profile.py
@@ -100,7 +100,7 @@ def profile_decorator(**options):
"""
Profile a single function call.
-
+
Used around a function, like::
@profile_decorator(options...)
@@ -203,14 +203,14 @@ class DecoratedProfile(object):
# We captured an exception earlier, now we re-raise it
six.reraise(exc_info[0], exc_info[1], exc_info[2])
return result
-
+
def format_function(self, func, *args, **kw):
args = map(repr, args)
args.extend(
['%s=%r' % (k, v) for k, v in kw.items()])
return '%s(%s)' % (func.__name__, ', '.join(args))
-
-
+
+
def make_profile_middleware(
app, global_conf,
log_filename='profile.log.tmp',
diff --git a/paste/debug/testserver.py b/paste/debug/testserver.py
index 4817161..8044c7c 100755
--- a/paste/debug/testserver.py
+++ b/paste/debug/testserver.py
@@ -28,7 +28,7 @@ class WSGIRegressionServer(WSGIServer):
self.pending = []
self.timeout = self.defaulttimeout
# this is a local connection, be quick
- self.socket.settimeout(2)
+ self.socket.settimeout(2)
def serve_forever(self):
from threading import Thread
thread = Thread(target=self.serve_pending)
@@ -75,13 +75,13 @@ if __name__ == '__main__':
def fetch(path):
# tell the server to humor exactly one more request
server.accept(1)
- # not needed; but this is what you do if the server
+ # not needed; but this is what you do if the server
# may not respond in a resonable time period
import socket
socket.setdefaulttimeout(5)
# build a uri, fetch and return
return urlopen(baseuri + path).read()
-
+
assert "PATH_INFO: /foo" in fetch("/foo")
assert "PATH_INFO: /womble" in fetch("/womble")
diff --git a/paste/debug/watchthreads.py b/paste/debug/watchthreads.py
index c877942..b06ccea 100644
--- a/paste/debug/watchthreads.py
+++ b/paste/debug/watchthreads.py
@@ -123,7 +123,7 @@ page_template = HTMLTemplate('''
}
return false
">&#9656; Show environ</a>
-
+
<div id="environ-{{thread.thread_id}}" style="display: none">
{{if thread.environ:}}
<table class="environ">
@@ -221,7 +221,7 @@ class WatchThreads(object):
thread.uri_short = shorten(thread.uri)
thread.environ = worker_environ
thread.traceback = traceback_thread(thread_id)
-
+
page = page_template.substitute(
title="Thread Pool Worker Tracker",
nworkers=nworkers,
@@ -255,7 +255,7 @@ class WatchThreads(object):
exc = httpexceptions.HTTPFound(
headers=[('Location', script_name+'?kill=%s' % thread_id)])
return exc(environ, start_response)
-
+
def traceback_thread(thread_id):
"""
Returns a plain-text traceback of the given thread, or None if it
@@ -296,7 +296,7 @@ def format_environ(environ):
key=cgi.escape(str(key)),
value='Error in <code>repr()</code>: %s' % e))
return ''.join(environ_rows)
-
+
def format_time(time_length):
if time_length >= 60*60:
# More than an hour
diff --git a/paste/debug/wdg_validate.py b/paste/debug/wdg_validate.py
index d3678fb..225baf9 100644
--- a/paste/debug/wdg_validate.py
+++ b/paste/debug/wdg_validate.py
@@ -6,10 +6,7 @@ Middleware that tests the validity of all generated HTML using the
"""
from cStringIO import StringIO
-try:
- import subprocess
-except ImportError:
- from paste.util import subprocess24 as subprocess
+import subprocess
from paste.response import header_value
import re
import cgi