mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-18 11:55:46 +08:00
remove all trailling spaces
This commit is contained in:
parent
b4392a5e4f
commit
8e32204222
@ -50,7 +50,7 @@ class AuthenticatedHandler(web.RequestHandler):
|
|||||||
if not self.application.password:
|
if not self.application.password:
|
||||||
user_id = 'anonymous'
|
user_id = 'anonymous'
|
||||||
return user_id
|
return user_id
|
||||||
|
|
||||||
|
|
||||||
class NBBrowserHandler(AuthenticatedHandler):
|
class NBBrowserHandler(AuthenticatedHandler):
|
||||||
@web.authenticated
|
@web.authenticated
|
||||||
@ -176,13 +176,13 @@ class AuthenticatedZMQStreamHandler(ZMQStreamHandler):
|
|||||||
self.session = Session()
|
self.session = Session()
|
||||||
self.save_on_message = self.on_message
|
self.save_on_message = self.on_message
|
||||||
self.on_message = self.on_first_message
|
self.on_message = self.on_first_message
|
||||||
|
|
||||||
def get_current_user(self):
|
def get_current_user(self):
|
||||||
user_id = self.get_secure_cookie("user")
|
user_id = self.get_secure_cookie("user")
|
||||||
if user_id == '' or (user_id is None and not self.application.password):
|
if user_id == '' or (user_id is None and not self.application.password):
|
||||||
user_id = 'anonymous'
|
user_id = 'anonymous'
|
||||||
return user_id
|
return user_id
|
||||||
|
|
||||||
def _inject_cookie_message(self, msg):
|
def _inject_cookie_message(self, msg):
|
||||||
"""Inject the first message, which is the document cookie,
|
"""Inject the first message, which is the document cookie,
|
||||||
for authentication."""
|
for authentication."""
|
||||||
@ -193,14 +193,14 @@ class AuthenticatedZMQStreamHandler(ZMQStreamHandler):
|
|||||||
self._cookies = Cookie.SimpleCookie(msg)
|
self._cookies = Cookie.SimpleCookie(msg)
|
||||||
except:
|
except:
|
||||||
logging.warn("couldn't parse cookie string: %s",msg, exc_info=True)
|
logging.warn("couldn't parse cookie string: %s",msg, exc_info=True)
|
||||||
|
|
||||||
def on_first_message(self, msg):
|
def on_first_message(self, msg):
|
||||||
self._inject_cookie_message(msg)
|
self._inject_cookie_message(msg)
|
||||||
if self.get_current_user() is None:
|
if self.get_current_user() is None:
|
||||||
logging.warn("Couldn't authenticate WebSocket connection")
|
logging.warn("Couldn't authenticate WebSocket connection")
|
||||||
raise web.HTTPError(403)
|
raise web.HTTPError(403)
|
||||||
self.on_message = self.save_on_message
|
self.on_message = self.save_on_message
|
||||||
|
|
||||||
|
|
||||||
class IOPubHandler(AuthenticatedZMQStreamHandler):
|
class IOPubHandler(AuthenticatedZMQStreamHandler):
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ class IOPubHandler(AuthenticatedZMQStreamHandler):
|
|||||||
self._beating = False
|
self._beating = False
|
||||||
self.iopub_stream = None
|
self.iopub_stream = None
|
||||||
self.hb_stream = None
|
self.hb_stream = None
|
||||||
|
|
||||||
def on_first_message(self, msg):
|
def on_first_message(self, msg):
|
||||||
try:
|
try:
|
||||||
super(IOPubHandler, self).on_first_message(msg)
|
super(IOPubHandler, self).on_first_message(msg)
|
||||||
@ -231,12 +231,12 @@ class IOPubHandler(AuthenticatedZMQStreamHandler):
|
|||||||
else:
|
else:
|
||||||
self.iopub_stream.on_recv(self._on_zmq_reply)
|
self.iopub_stream.on_recv(self._on_zmq_reply)
|
||||||
self.start_hb(self.kernel_died)
|
self.start_hb(self.kernel_died)
|
||||||
|
|
||||||
def on_message(self, msg):
|
def on_message(self, msg):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def on_close(self):
|
def on_close(self):
|
||||||
# This method can be called twice, once by self.kernel_died and once
|
# This method can be called twice, once by self.kernel_died and once
|
||||||
# from the WebSocket close event. If the WebSocket connection is
|
# from the WebSocket close event. If the WebSocket connection is
|
||||||
# closed before the ZMQ streams are setup, they could be None.
|
# closed before the ZMQ streams are setup, they could be None.
|
||||||
self.stop_hb()
|
self.stop_hb()
|
||||||
@ -245,7 +245,7 @@ class IOPubHandler(AuthenticatedZMQStreamHandler):
|
|||||||
self.iopub_stream.close()
|
self.iopub_stream.close()
|
||||||
if self.hb_stream is not None and not self.hb_stream.closed():
|
if self.hb_stream is not None and not self.hb_stream.closed():
|
||||||
self.hb_stream.close()
|
self.hb_stream.close()
|
||||||
|
|
||||||
def start_hb(self, callback):
|
def start_hb(self, callback):
|
||||||
"""Start the heartbeating and call the callback if the kernel dies."""
|
"""Start the heartbeating and call the callback if the kernel dies."""
|
||||||
if not self._beating:
|
if not self._beating:
|
||||||
|
@ -88,18 +88,18 @@ def extract_version(mod):
|
|||||||
def test_for(item, min_version=None, callback=extract_version):
|
def test_for(item, min_version=None, callback=extract_version):
|
||||||
"""Test to see if item is importable, and optionally check against a minimum
|
"""Test to see if item is importable, and optionally check against a minimum
|
||||||
version.
|
version.
|
||||||
|
|
||||||
If min_version is given, the default behavior is to check against the
|
If min_version is given, the default behavior is to check against the
|
||||||
`__version__` attribute of the item, but specifying `callback` allows you to
|
`__version__` attribute of the item, but specifying `callback` allows you to
|
||||||
extract the value you are interested in. e.g::
|
extract the value you are interested in. e.g::
|
||||||
|
|
||||||
In [1]: import sys
|
In [1]: import sys
|
||||||
|
|
||||||
In [2]: from IPython.testing.iptest import test_for
|
In [2]: from IPython.testing.iptest import test_for
|
||||||
|
|
||||||
In [3]: test_for('sys', (2,6), callback=lambda sys: sys.version_info)
|
In [3]: test_for('sys', (2,6), callback=lambda sys: sys.version_info)
|
||||||
Out[3]: True
|
Out[3]: True
|
||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
check = import_item(item)
|
check = import_item(item)
|
||||||
@ -112,7 +112,7 @@ def test_for(item, min_version=None, callback=extract_version):
|
|||||||
if callback:
|
if callback:
|
||||||
# extra processing step to get version to compare
|
# extra processing step to get version to compare
|
||||||
check = callback(check)
|
check = callback(check)
|
||||||
|
|
||||||
return check >= min_version
|
return check >= min_version
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
@ -156,7 +156,7 @@ def report():
|
|||||||
|
|
||||||
avail = []
|
avail = []
|
||||||
not_avail = []
|
not_avail = []
|
||||||
|
|
||||||
for k, is_avail in have.items():
|
for k, is_avail in have.items():
|
||||||
if is_avail:
|
if is_avail:
|
||||||
avail.append(k)
|
avail.append(k)
|
||||||
@ -172,7 +172,7 @@ def report():
|
|||||||
out.append('\nTools and libraries NOT available at test time:\n')
|
out.append('\nTools and libraries NOT available at test time:\n')
|
||||||
not_avail.sort()
|
not_avail.sort()
|
||||||
out.append(' ' + ' '.join(not_avail)+'\n')
|
out.append(' ' + ' '.join(not_avail)+'\n')
|
||||||
|
|
||||||
return ''.join(out)
|
return ''.join(out)
|
||||||
|
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ def make_exclude():
|
|||||||
# Simple utility to make IPython paths more readably, we need a lot of
|
# Simple utility to make IPython paths more readably, we need a lot of
|
||||||
# these below
|
# these below
|
||||||
ipjoin = lambda *paths: pjoin('IPython', *paths)
|
ipjoin = lambda *paths: pjoin('IPython', *paths)
|
||||||
|
|
||||||
exclusions = [ipjoin('external'),
|
exclusions = [ipjoin('external'),
|
||||||
pjoin('IPython_doctest_plugin'),
|
pjoin('IPython_doctest_plugin'),
|
||||||
ipjoin('quarantine'),
|
ipjoin('quarantine'),
|
||||||
@ -207,7 +207,7 @@ def make_exclude():
|
|||||||
|
|
||||||
if not have['wx']:
|
if not have['wx']:
|
||||||
exclusions.append(ipjoin('lib', 'inputhookwx'))
|
exclusions.append(ipjoin('lib', 'inputhookwx'))
|
||||||
|
|
||||||
# We do this unconditionally, so that the test suite doesn't import
|
# We do this unconditionally, so that the test suite doesn't import
|
||||||
# gtk, changing the default encoding and masking some unicode bugs.
|
# gtk, changing the default encoding and masking some unicode bugs.
|
||||||
exclusions.append(ipjoin('lib', 'inputhookgtk'))
|
exclusions.append(ipjoin('lib', 'inputhookgtk'))
|
||||||
@ -229,7 +229,7 @@ def make_exclude():
|
|||||||
exclusions.append(ipjoin('parallel'))
|
exclusions.append(ipjoin('parallel'))
|
||||||
elif not have['qt']:
|
elif not have['qt']:
|
||||||
exclusions.append(ipjoin('frontend', 'qt'))
|
exclusions.append(ipjoin('frontend', 'qt'))
|
||||||
|
|
||||||
if not have['pymongo']:
|
if not have['pymongo']:
|
||||||
exclusions.append(ipjoin('parallel', 'controller', 'mongodb'))
|
exclusions.append(ipjoin('parallel', 'controller', 'mongodb'))
|
||||||
exclusions.append(ipjoin('parallel', 'tests', 'test_mongodb'))
|
exclusions.append(ipjoin('parallel', 'tests', 'test_mongodb'))
|
||||||
@ -259,7 +259,7 @@ class IPTester(object):
|
|||||||
call_args = None
|
call_args = None
|
||||||
#: list, process ids of subprocesses we start (for cleanup)
|
#: list, process ids of subprocesses we start (for cleanup)
|
||||||
pids = None
|
pids = None
|
||||||
|
|
||||||
def __init__(self, runner='iptest', params=None):
|
def __init__(self, runner='iptest', params=None):
|
||||||
"""Create new test runner."""
|
"""Create new test runner."""
|
||||||
p = os.path
|
p = os.path
|
||||||
@ -303,7 +303,7 @@ class IPTester(object):
|
|||||||
retcode = subp.wait()
|
retcode = subp.wait()
|
||||||
self.pids.pop()
|
self.pids.pop()
|
||||||
return retcode
|
return retcode
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Run the stored commands"""
|
"""Run the stored commands"""
|
||||||
try:
|
try:
|
||||||
@ -318,7 +318,7 @@ class IPTester(object):
|
|||||||
|
|
||||||
if not hasattr(os, 'kill'):
|
if not hasattr(os, 'kill'):
|
||||||
return
|
return
|
||||||
|
|
||||||
for pid in self.pids:
|
for pid in self.pids:
|
||||||
try:
|
try:
|
||||||
print 'Cleaning stale PID:', pid
|
print 'Cleaning stale PID:', pid
|
||||||
@ -326,7 +326,7 @@ class IPTester(object):
|
|||||||
except OSError:
|
except OSError:
|
||||||
# This is just a best effort, if we fail or the process was
|
# This is just a best effort, if we fail or the process was
|
||||||
# really gone, ignore it.
|
# really gone, ignore it.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def make_runners():
|
def make_runners():
|
||||||
@ -336,10 +336,10 @@ def make_runners():
|
|||||||
# Packages to be tested via nose, that only depend on the stdlib
|
# Packages to be tested via nose, that only depend on the stdlib
|
||||||
nose_pkg_names = ['config', 'core', 'extensions', 'frontend', 'lib',
|
nose_pkg_names = ['config', 'core', 'extensions', 'frontend', 'lib',
|
||||||
'scripts', 'testing', 'utils', 'nbformat' ]
|
'scripts', 'testing', 'utils', 'nbformat' ]
|
||||||
|
|
||||||
if have['zmq']:
|
if have['zmq']:
|
||||||
nose_pkg_names.append('parallel')
|
nose_pkg_names.append('parallel')
|
||||||
|
|
||||||
# For debugging this code, only load quick stuff
|
# For debugging this code, only load quick stuff
|
||||||
#nose_pkg_names = ['core', 'extensions'] # dbg
|
#nose_pkg_names = ['core', 'extensions'] # dbg
|
||||||
|
|
||||||
@ -348,29 +348,29 @@ def make_runners():
|
|||||||
|
|
||||||
# Make runners
|
# Make runners
|
||||||
runners = [ (v, IPTester('iptest', params=v)) for v in nose_packages ]
|
runners = [ (v, IPTester('iptest', params=v)) for v in nose_packages ]
|
||||||
|
|
||||||
return runners
|
return runners
|
||||||
|
|
||||||
|
|
||||||
def run_iptest():
|
def run_iptest():
|
||||||
"""Run the IPython test suite using nose.
|
"""Run the IPython test suite using nose.
|
||||||
|
|
||||||
This function is called when this script is **not** called with the form
|
This function is called when this script is **not** called with the form
|
||||||
`iptest all`. It simply calls nose with appropriate command line flags
|
`iptest all`. It simply calls nose with appropriate command line flags
|
||||||
and accepts all of the standard nose arguments.
|
and accepts all of the standard nose arguments.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
warnings.filterwarnings('ignore',
|
warnings.filterwarnings('ignore',
|
||||||
'This will be removed soon. Use IPython.testing.util instead')
|
'This will be removed soon. Use IPython.testing.util instead')
|
||||||
|
|
||||||
argv = sys.argv + [ '--detailed-errors', # extra info in tracebacks
|
argv = sys.argv + [ '--detailed-errors', # extra info in tracebacks
|
||||||
|
|
||||||
# Loading ipdoctest causes problems with Twisted, but
|
# Loading ipdoctest causes problems with Twisted, but
|
||||||
# our test suite runner now separates things and runs
|
# our test suite runner now separates things and runs
|
||||||
# all Twisted tests with trial.
|
# all Twisted tests with trial.
|
||||||
'--with-ipdoctest',
|
'--with-ipdoctest',
|
||||||
'--ipdoctest-tests','--ipdoctest-extension=txt',
|
'--ipdoctest-tests','--ipdoctest-extension=txt',
|
||||||
|
|
||||||
# We add --exe because of setuptools' imbecility (it
|
# We add --exe because of setuptools' imbecility (it
|
||||||
# blindly does chmod +x on ALL files). Nose does the
|
# blindly does chmod +x on ALL files). Nose does the
|
||||||
# right thing and it tries to avoid executables,
|
# right thing and it tries to avoid executables,
|
||||||
@ -402,7 +402,7 @@ def run_iptest():
|
|||||||
|
|
||||||
def run_iptestall():
|
def run_iptestall():
|
||||||
"""Run the entire IPython test suite by calling nose and trial.
|
"""Run the entire IPython test suite by calling nose and trial.
|
||||||
|
|
||||||
This function constructs :class:`IPTester` instances for all IPython
|
This function constructs :class:`IPTester` instances for all IPython
|
||||||
modules and package and then runs each of them. This causes the modules
|
modules and package and then runs each of them. This causes the modules
|
||||||
and packages of IPython to be tested each in their own subprocess using
|
and packages of IPython to be tested each in their own subprocess using
|
||||||
|
30
setupbase.py
30
setupbase.py
@ -43,7 +43,7 @@ pjoin = os.path.join
|
|||||||
def oscmd(s):
|
def oscmd(s):
|
||||||
print(">", s)
|
print(">", s)
|
||||||
os.system(s)
|
os.system(s)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
execfile
|
execfile
|
||||||
except NameError:
|
except NameError:
|
||||||
@ -120,7 +120,7 @@ def find_package_data():
|
|||||||
"""
|
"""
|
||||||
# This is not enough for these things to appear in an sdist.
|
# This is not enough for these things to appear in an sdist.
|
||||||
# We need to muck with the MANIFEST to get this to work
|
# We need to muck with the MANIFEST to get this to work
|
||||||
|
|
||||||
# walk notebook resources:
|
# walk notebook resources:
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
os.chdir(os.path.join('IPython', 'frontend', 'html', 'notebook'))
|
os.chdir(os.path.join('IPython', 'frontend', 'html', 'notebook'))
|
||||||
@ -130,7 +130,7 @@ def find_package_data():
|
|||||||
for parent, dirs, files in static_walk:
|
for parent, dirs, files in static_walk:
|
||||||
for f in files:
|
for f in files:
|
||||||
static_data.append(os.path.join(parent, f))
|
static_data.append(os.path.join(parent, f))
|
||||||
|
|
||||||
package_data = {
|
package_data = {
|
||||||
'IPython.config.profile' : ['README', '*/*.py'],
|
'IPython.config.profile' : ['README', '*/*.py'],
|
||||||
'IPython.testing' : ['*.txt'],
|
'IPython.testing' : ['*.txt'],
|
||||||
@ -151,23 +151,23 @@ def make_dir_struct(tag,base,out_base):
|
|||||||
|
|
||||||
XXX - this needs a proper docstring!
|
XXX - this needs a proper docstring!
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# we'll use these a lot below
|
# we'll use these a lot below
|
||||||
lbase = len(base)
|
lbase = len(base)
|
||||||
pathsep = os.path.sep
|
pathsep = os.path.sep
|
||||||
lpathsep = len(pathsep)
|
lpathsep = len(pathsep)
|
||||||
|
|
||||||
out = []
|
out = []
|
||||||
for (dirpath,dirnames,filenames) in os.walk(base):
|
for (dirpath,dirnames,filenames) in os.walk(base):
|
||||||
# we need to strip out the dirpath from the base to map it to the
|
# we need to strip out the dirpath from the base to map it to the
|
||||||
# output (installation) path. This requires possibly stripping the
|
# output (installation) path. This requires possibly stripping the
|
||||||
# path separator, because otherwise pjoin will not work correctly
|
# path separator, because otherwise pjoin will not work correctly
|
||||||
# (pjoin('foo/','/bar') returns '/bar').
|
# (pjoin('foo/','/bar') returns '/bar').
|
||||||
|
|
||||||
dp_eff = dirpath[lbase:]
|
dp_eff = dirpath[lbase:]
|
||||||
if dp_eff.startswith(pathsep):
|
if dp_eff.startswith(pathsep):
|
||||||
dp_eff = dp_eff[lpathsep:]
|
dp_eff = dp_eff[lpathsep:]
|
||||||
# The output path must be anchored at the out_base marker
|
# The output path must be anchored at the out_base marker
|
||||||
out_path = pjoin(out_base,dp_eff)
|
out_path = pjoin(out_base,dp_eff)
|
||||||
# Now we can generate the final filenames. Since os.walk only produces
|
# Now we can generate the final filenames. Since os.walk only produces
|
||||||
# filenames, we must join back with the dirpath to get full valid file
|
# filenames, we must join back with the dirpath to get full valid file
|
||||||
@ -178,7 +178,7 @@ def make_dir_struct(tag,base,out_base):
|
|||||||
out.append((out_path, pfiles))
|
out.append((out_path, pfiles))
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
def find_data_files():
|
def find_data_files():
|
||||||
"""
|
"""
|
||||||
@ -186,10 +186,10 @@ def find_data_files():
|
|||||||
|
|
||||||
Most of these are docs.
|
Most of these are docs.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
docdirbase = pjoin('share', 'doc', 'ipython')
|
docdirbase = pjoin('share', 'doc', 'ipython')
|
||||||
manpagebase = pjoin('share', 'man', 'man1')
|
manpagebase = pjoin('share', 'man', 'man1')
|
||||||
|
|
||||||
# Simple file lists can be made by hand
|
# Simple file lists can be made by hand
|
||||||
manpages = filter(isfile, glob(pjoin('docs','man','*.1.gz')))
|
manpages = filter(isfile, glob(pjoin('docs','man','*.1.gz')))
|
||||||
if not manpages:
|
if not manpages:
|
||||||
@ -241,19 +241,19 @@ def make_man_update_target(manpage):
|
|||||||
gz_cmd = ( "cd %(man_dir)s && gzip -9c %(manpage)s > %(manpage_gz)s" %
|
gz_cmd = ( "cd %(man_dir)s && gzip -9c %(manpage)s > %(manpage_gz)s" %
|
||||||
locals() )
|
locals() )
|
||||||
return (manpath_gz, [manpath], gz_cmd)
|
return (manpath_gz, [manpath], gz_cmd)
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# Find scripts
|
# Find scripts
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
def find_scripts(entry_points=False, suffix=''):
|
def find_scripts(entry_points=False, suffix=''):
|
||||||
"""Find IPython's scripts.
|
"""Find IPython's scripts.
|
||||||
|
|
||||||
if entry_points is True:
|
if entry_points is True:
|
||||||
return setuptools entry_point-style definitions
|
return setuptools entry_point-style definitions
|
||||||
else:
|
else:
|
||||||
return file paths of plain scripts [default]
|
return file paths of plain scripts [default]
|
||||||
|
|
||||||
suffix is appended to script names if entry_points is True, so that the
|
suffix is appended to script names if entry_points is True, so that the
|
||||||
Python 3 scripts get named "ipython3" etc.
|
Python 3 scripts get named "ipython3" etc.
|
||||||
"""
|
"""
|
||||||
@ -293,7 +293,7 @@ def find_scripts(entry_points=False, suffix=''):
|
|||||||
|
|
||||||
def check_for_dependencies():
|
def check_for_dependencies():
|
||||||
"""Check for IPython's dependencies.
|
"""Check for IPython's dependencies.
|
||||||
|
|
||||||
This function should NOT be called if running under setuptools!
|
This function should NOT be called if running under setuptools!
|
||||||
"""
|
"""
|
||||||
from setupext.setupext import (
|
from setupext.setupext import (
|
||||||
@ -308,7 +308,7 @@ def check_for_dependencies():
|
|||||||
print_status('platform', sys.platform)
|
print_status('platform', sys.platform)
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
print_status('Windows version', sys.getwindowsversion())
|
print_status('Windows version', sys.getwindowsversion())
|
||||||
|
|
||||||
print_raw("")
|
print_raw("")
|
||||||
print_raw("OPTIONAL DEPENDENCIES")
|
print_raw("OPTIONAL DEPENDENCIES")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user