mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-16 14:33:00 +00:00
Merge pull request #65 from minrk/six
use six instead of IPython.py3compat
This commit is contained in:
@@ -9,7 +9,6 @@ import io
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from six import text_type
|
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -667,8 +666,10 @@ class JupyterHubApp(Application):
|
|||||||
answer = ask()
|
answer = ask()
|
||||||
if answer.startswith('n'):
|
if answer.startswith('n'):
|
||||||
return
|
return
|
||||||
|
|
||||||
config_text = text_type(self.generate_config_file(), 'utf8')
|
config_text = self.generate_config_file()
|
||||||
|
if isinstance(config_text, bytes):
|
||||||
|
config_text = config_text.decode('utf8')
|
||||||
print("Writing default config to: %s" % self.config_file)
|
print("Writing default config to: %s" % self.config_file)
|
||||||
with io.open(self.config_file, encoding='utf8', mode='w') as f:
|
with io.open(self.config_file, encoding='utf8', mode='w') as f:
|
||||||
f.write(config_text)
|
f.write(config_text)
|
||||||
|
@@ -9,6 +9,8 @@ import json
|
|||||||
import socket
|
import socket
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from six import text_type
|
||||||
|
|
||||||
from tornado import gen
|
from tornado import gen
|
||||||
from tornado.log import app_log
|
from tornado.log import app_log
|
||||||
from tornado.httpclient import HTTPRequest, AsyncHTTPClient, HTTPError
|
from tornado.httpclient import HTTPRequest, AsyncHTTPClient, HTTPError
|
||||||
@@ -24,8 +26,6 @@ from sqlalchemy.orm import sessionmaker, relationship, backref
|
|||||||
from sqlalchemy.pool import StaticPool
|
from sqlalchemy.pool import StaticPool
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
|
|
||||||
from IPython.utils.py3compat import str_to_unicode
|
|
||||||
|
|
||||||
from .utils import random_port, url_path_join, wait_for_server, wait_for_http_server
|
from .utils import random_port, url_path_join, wait_for_server, wait_for_http_server
|
||||||
|
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ def new_token(*args, **kwargs):
|
|||||||
|
|
||||||
For now, just UUIDs.
|
For now, just UUIDs.
|
||||||
"""
|
"""
|
||||||
return str_to_unicode(uuid.uuid4().hex)
|
return text_type(uuid.uuid4().hex)
|
||||||
|
|
||||||
|
|
||||||
class JSONDict(TypeDecorator):
|
class JSONDict(TypeDecorator):
|
||||||
|
@@ -10,7 +10,7 @@ except ImportError:
|
|||||||
|
|
||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
|
|
||||||
from IPython.utils.py3compat import unicode_type
|
from six import text_type
|
||||||
|
|
||||||
from ..spawner import LocalProcessSpawner
|
from ..spawner import LocalProcessSpawner
|
||||||
from ..app import JupyterHubApp
|
from ..app import JupyterHubApp
|
||||||
@@ -19,9 +19,9 @@ from .. import orm
|
|||||||
|
|
||||||
def mock_authenticate(username, password, service='login'):
|
def mock_authenticate(username, password, service='login'):
|
||||||
# mimic simplepam's failure to handle unicode
|
# mimic simplepam's failure to handle unicode
|
||||||
if isinstance(username, unicode_type):
|
if isinstance(username, text_type):
|
||||||
return False
|
return False
|
||||||
if isinstance(password, unicode_type):
|
if isinstance(password, text_type):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# just use equality for testing
|
# just use equality for testing
|
||||||
|
@@ -1,11 +1,27 @@
|
|||||||
"""Test the JupyterHubApp entry point"""
|
"""Test the JupyterHubApp entry point"""
|
||||||
|
|
||||||
|
import io
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
from subprocess import check_output
|
from subprocess import check_output
|
||||||
|
from tempfile import NamedTemporaryFile
|
||||||
|
|
||||||
def test_help_all():
|
def test_help_all():
|
||||||
out = check_output([sys.executable, '-m', 'jupyterhub', '--help-all']).decode('utf8', 'replace')
|
out = check_output([sys.executable, '-m', 'jupyterhub', '--help-all']).decode('utf8', 'replace')
|
||||||
assert u'--ip' in out
|
assert u'--ip' in out
|
||||||
assert u'--JupyterHubApp.ip' in out
|
assert u'--JupyterHubApp.ip' in out
|
||||||
|
|
||||||
|
def test_generate_config():
|
||||||
|
with NamedTemporaryFile(prefix='jupyter_hub_config', suffix='.py') as tf:
|
||||||
|
cfg_file = tf.name
|
||||||
|
|
||||||
|
out = check_output([sys.executable, '-m', 'jupyterhub',
|
||||||
|
'--generate-config', '-f', cfg_file]
|
||||||
|
).decode('utf8', 'replace')
|
||||||
|
assert os.path.exists(cfg_file)
|
||||||
|
with io.open(cfg_file) as f:
|
||||||
|
cfg_text = f.read()
|
||||||
|
os.remove(cfg_file)
|
||||||
|
assert cfg_file in out
|
||||||
|
assert 'Spawner.cmd' in cfg_text
|
||||||
|
assert 'Authenticator.whitelist' in cfg_text
|
||||||
|
Reference in New Issue
Block a user