drop support for old Python, IPython < 3

Require IPython >= 3.0, Python >= 3.3
This commit is contained in:
Min RK
2014-10-31 13:03:50 -07:00
parent 83569221b9
commit 40a99e61ac
20 changed files with 110 additions and 173 deletions

View File

@@ -5,34 +5,17 @@
from binascii import b2a_hex
import errno
import getpass
import hashlib
import os
import socket
import uuid
from six import text_type
from tornado import web, gen, ioloop
from tornado.httpclient import AsyncHTTPClient, HTTPError
from tornado.log import app_log
from IPython.html.utils import url_path_join
try:
# make TimeoutError importable on Python >= 3.3
TimeoutError = TimeoutError
except NameError:
# python < 3.3
class TimeoutError(Exception):
pass
def getuser_unicode():
"""
Call getpass.getuser, ensuring that the output is returned as unicode.
"""
return text_type(getpass.getuser())
def random_port():
"""get a single random port"""
@@ -147,7 +130,7 @@ def new_token(*args, **kwargs):
For now, just UUIDs.
"""
return text_type(uuid.uuid4().hex)
return uuid.uuid4().hex
def hash_token(token, salt=8, rounds=16384, algorithm='sha512'):
@@ -169,7 +152,7 @@ def hash_token(token, salt=8, rounds=16384, algorithm='sha512'):
h.update(btoken)
digest = h.hexdigest()
return u"{algorithm}:{rounds}:{salt}:{digest}".format(**locals())
return "{algorithm}:{rounds}:{salt}:{digest}".format(**locals())
def compare_token(compare, token):