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