##// END OF EJS Templates
This feature was discussed in #6123, but it doesn't look like anything was ever incorporated into the IPython Notebook....
This feature was discussed in #6123, but it doesn't look like anything was ever incorporated into the IPython Notebook. Here's a brief overview of the changes: - Display of messages from other clients can be toggled on and off from within a notebook, either using the ``<M-m>e`` keyboard shortcut in the web UI, or through the option in the "Kernel" menu. - notebook.js controls whether messages are displayed through a callback that is invoked from kernel.js when no callbacks are available for a message. - The UI displays ``execute_input`` messages originating from an other clients in new cells at the end of the notebook. Output messages (``execute_result`` et al.) will only be displayed if a cell exists with a matching message ID. Pending design questions: - Should each ``execute_input`` message cause a new cell to be created? - Should new cells be placed at the end of the notebook, or elsewhere? If the latter, what criteria should be followed?

File last commit:

r17983:2f82af5a
r19164:17ac8ca3
Show More
submodule.py
105 lines | 3.3 KiB | text/x-python | PythonLexer
"""utilities for checking submodule status"""
#-----------------------------------------------------------------------------
# Copyright (C) 2013 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
import os
import subprocess
import sys
#-----------------------------------------------------------------------------
# Globals
#-----------------------------------------------------------------------------
pjoin = os.path.join
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------
def ipython_parent():
"""return IPython's parent (i.e. root if run from git)"""
from IPython.utils.path import get_ipython_package_dir
return os.path.abspath(os.path.dirname(get_ipython_package_dir()))
def ipython_submodules(root):
"""return IPython submodules relative to root"""
return [
pjoin(root, 'IPython', 'html', 'static', 'components'),
]
def is_repo(d):
"""is d a git repo?"""
if not os.path.exists(pjoin(d, '.git')):
return False
proc = subprocess.Popen('git status',
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
cwd=d,
)
status, _ = proc.communicate()
return status == 0
def check_submodule_status(root=None):
"""check submodule status
Has three return values:
'missing' - submodules are absent
'unclean' - submodules have unstaged changes
'clean' - all submodules are up to date
"""
if hasattr(sys, "frozen"):
# frozen via py2exe or similar, don't bother
return 'clean'
if not root:
root = ipython_parent()
if not is_repo(root):
# not in git, assume clean
return 'clean'
submodules = ipython_submodules(root)
for submodule in submodules:
if not os.path.exists(submodule):
return 'missing'
# Popen can't handle unicode cwd on Windows Python 2
if sys.platform == 'win32' and sys.version_info[0] < 3 \
and not isinstance(root, bytes):
root = root.encode(sys.getfilesystemencoding() or 'ascii')
# check with git submodule status
proc = subprocess.Popen('git submodule status',
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
cwd=root,
)
status, _ = proc.communicate()
status = status.decode("ascii", "replace")
for line in status.splitlines():
if line.startswith('-'):
return 'missing'
elif line.startswith('+'):
return 'unclean'
return 'clean'
def update_submodules(repo_dir):
"""update submodules in a repo"""
subprocess.check_call("git submodule init", cwd=repo_dir, shell=True)
subprocess.check_call("git submodule update --recursive", cwd=repo_dir, shell=True)