Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion blueox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def decode_stream(stream):

while True:
try:
data = stream.next()
data = next(stream)
except StopIteration:
break

Expand Down
4 changes: 2 additions & 2 deletions blueox/contrib/django/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def process_request(self, request):
blueox.set('path', request.path)

headers = {}
for k, v in request.META.iteritems():
for k, v in request.META.items():
if k.startswith('HTTP_') or k in ('CONTENT_LENGTH', 'CONTENT_TYPE'):
headers[k] = v
blueox.set('headers', headers)
Expand Down Expand Up @@ -60,7 +60,7 @@ def process_response(self, request, response):
blueox.set('response_size', len(response.content))

headers = {}
for k, v in response.items():
for k, v in list(response.items()):
headers[k] = v

blueox.set('response_headers', headers)
Expand Down
2 changes: 1 addition & 1 deletion blueox/contrib/flask/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def before_request(self, *args, **kwargs):
blueox.set('path', request.path)

headers = {}
for k, v in request.environ.iteritems():
for k, v in request.environ.items():
if (
k.startswith('HTTP_') or k in
('CONTENT_LENGTH', 'CONTENT_TYPE')):
Expand Down
2 changes: 1 addition & 1 deletion blueox/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def send(context):
log.debug("Sending msg")
threadLocal.zmq_socket.send_multipart(
(meta_data, context_data), zmq.NOBLOCK)
except zmq.ZMQError, e:
except zmq.ZMQError as e:
log.exception("Failed sending blueox event, buffer full?")
else:
log.info("Skipping sending event %s", context.name)
Expand Down
2 changes: 1 addition & 1 deletion blueox/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def filter_log_files_for_active(log_files):
for lf in log_files:
files_by_type[lf.type_name].append(lf)

for type_files in files_by_type.values():
for type_files in list(files_by_type.values()):
type_files.sort(key=lambda f: f.sort_dt)

# We assume only the last log file in the list can be possibly be in
Expand Down
2 changes: 1 addition & 1 deletion blueox/tornado_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def __init__(self, *args, **kwargs):
def fetch(self, request, callback=None, **kwargs):
start_time = time.time()

if isinstance(request, basestring):
if isinstance(request, str):
request = tornado.httpclient.HTTPRequest(url=request, **kwargs)

ctx = blueox.Context(self.blueox_name)
Expand Down
2 changes: 1 addition & 1 deletion tests/store_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def test_range(self):
dt_str = dt.strftime('%Y%m%d%H')
full_path = os.path.join(self.log_path, date_str, "foo-{}.log".format(dt_str))
with io.open(full_path, "w") as f:
f.write(u"hi")
f.write("hi")

start_dt = datetime.datetime(2015, 5, 19, 1)
end_dt = datetime.datetime(2015, 5, 19, 3)
Expand Down
10 changes: 5 additions & 5 deletions tests/tornado_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def post(self):
blueox.set("start", True)
try:
f = yield http_client.fetch(self.request.body, request_timeout=0.5)
except tornado.httpclient.HTTPError, e:
except tornado.httpclient.HTTPError as e:
self.write("got it")
else:
self.write("nope")
Expand Down Expand Up @@ -120,7 +120,7 @@ def test_error(self):
assert_equal(len(self.log_ctx), 2)

found_exception = False
for ctx_list in self.log_ctx.values():
for ctx_list in list(self.log_ctx.values()):
for ctx in ctx_list:
if ctx.to_dict()['body'].get('exception'):
found_exception = True
Expand All @@ -137,7 +137,7 @@ def test_timeout_error(self):
#pprint.pprint(ctx.to_dict())

assert_equal(len(self.log_ctx), 1)
ctx = self.log_ctx[self.log_ctx.keys()[0]][0]
ctx = self.log_ctx[list(self.log_ctx.keys())[0]][0]
assert_equal(get_deep(ctx.to_dict(), 'body.response.code'), 599)

def test_recurse_timeout_error(self):
Expand All @@ -158,7 +158,7 @@ def test_recurse_timeout_error(self):

found_timeout = False
found_request = False
for ctx_list in self.log_ctx.values():
for ctx_list in list(self.log_ctx.values()):
for ctx in ctx_list:
c = ctx.to_dict()
if c['type'] == 'request.httpclient' and c['body']['response']['code'] == 599:
Expand Down Expand Up @@ -186,7 +186,7 @@ def test_context(self):
found_sync = None
found_async = None
found_client = 0
for ctx_list in self.log_ctx.values():
for ctx_list in list(self.log_ctx.values()):
for ctx in ctx_list:
if ctx.name == "request" and ctx.to_dict()['body']['async']:
assert_equal(len(ctx_list), 3)
Expand Down
26 changes: 13 additions & 13 deletions vendor/tornado_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Testify.

"""
import Cookie
import http.cookies
import tornado.httputil
from tornado.httpclient import AsyncHTTPClient
from tornado.httpserver import HTTPServer
Expand All @@ -12,7 +12,7 @@
import sys
import time
import json
import urlparse
import urllib.parse
import pprint

try:
Expand Down Expand Up @@ -202,9 +202,9 @@ def timeout_func():
# 2to3 isn't smart enough to convert three-argument raise
# statements correctly in some cases.
if isinstance(self.__failure[1], self.__failure[0]):
raise self.__failure[1], None, self.__failure[2]
raise self.__failure[1].with_traceback(self.__failure[2])
else:
raise self.__failure[0], self.__failure[1], self.__failure[2]
raise self.__failure[0](self.__failure[1]).with_traceback(self.__failure[2])
result = self.__stop_args
self.__stop_args = None
return result
Expand Down Expand Up @@ -277,10 +277,10 @@ def fetch(self, request, **kwargs):
timeout = kwargs.pop('timeout')

if hasattr(request, 'url'):
parsed = urlparse.urlparse(request.url)
parsed = urllib.parse.urlparse(request.url)
request.url = self.update_urlparsed(parsed)
else:
parsed = urlparse.urlparse(request)
parsed = urllib.parse.urlparse(request)
request = self.update_urlparsed(parsed)

if 'headers' in kwargs and not isinstance(kwargs['headers'], tornado.httputil.HTTPHeaders):
Expand All @@ -289,27 +289,27 @@ def fetch(self, request, **kwargs):
else:
kwargs.setdefault('headers', tornado.httputil.HTTPHeaders())

if 'body' in kwargs and not isinstance(kwargs['body'], basestring):
if 'body' in kwargs and not isinstance(kwargs['body'], str):
kwargs['body'] = json.dumps(kwargs['body'])
kwargs['headers']['Content-Type'] = 'application/json'

if 'cookies' in kwargs:
for cookie in kwargs['cookies']:
for val in cookie.values():
for val in list(cookie.values()):
kwargs['headers'].add('Cookie', val.OutputString(None))

if self.cookie_jar:
cookie = Cookie.SimpleCookie(self.cookie_jar)
for val in cookie.values():
cookie = http.cookies.SimpleCookie(self.cookie_jar)
for val in list(cookie.values()):
kwargs['headers'].add('Cookie', val.OutputString(None))

self.http_client.fetch(request, self.stop, **kwargs)
res = self.wait(timeout=timeout)

for cookie_val in res.headers.get_list('set-cookie'):
cookie = Cookie.SimpleCookie()
cookie = http.cookies.SimpleCookie()
cookie.load(cookie_val)
for val in cookie.values():
for val in list(cookie.values()):
if not val.value:
del self.cookie_jar[val.key]
else:
Expand Down Expand Up @@ -343,6 +343,6 @@ def get_url(self, path):
return 'http://localhost:%s%s' % (self.get_http_port(), path)

def update_urlparsed(self, parsed):
return urlparse.urlunparse(['http', 'localhost:%s' % self.get_http_port()] + list(parsed[2:]))
return urllib.parse.urlunparse(['http', 'localhost:%s' % self.get_http_port()] + list(parsed[2:]))