##// END OF EJS Templates
Adds configuration options to use Google Drive content manager...
Adds configuration options to use Google Drive content manager Adds the key contentmanager_js_source to webapp_settings that allows for specifying the content manager JavaScript source file. Also adds a NotebookManager subclass, ClientSideNotebookManager, which does minimal logic. This class is used when the JavaScript content manager doesn't use the Python notebook manager, but rather implements that logic client side, as is the case for the Google Drive based content manager. A sample command line that uses the Google Drive content manager, and the ClientSideNotebookManager, is ipython notebook --NotebookApp.webapp_settings="{'contentmanager_js_source': 'base/js/drive_contentmanager'}" --NotebookApp.notebook_manager_class="IPython.html.services.notebooks.clientsidenbmanager.ClientSideNotebookManager"

File last commit:

r17598:99ab024b
r18639:28c27a69
Show More
warn.py
81 lines | 2.5 KiB | text/x-python | PythonLexer
Brian Granger
Work to address the review comments on Fernando's branch....
r2498 # encoding: utf-8
"""
Utilities for warnings. Shoudn't we just use the built in warnings module.
"""
#-----------------------------------------------------------------------------
Matthias BUSSONNIER
update copyright to 2011/20xx-2011...
r5390 # Copyright (C) 2008-2011 The IPython Development Team
Brian Granger
Work to address the review comments on Fernando's branch....
r2498 #
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
Matthias BUSSONNIER
use print function in module with `print >>`
r7817 from __future__ import print_function
Brian Granger
Work to address the review comments on Fernando's branch....
r2498
import sys
Jonathan Frederic
Renamed *Widget to *,...
r17598 import warnings
Brian Granger
Work to address the review comments on Fernando's branch....
r2498
MinRK
io.Term.cin/out/err replaced by io.stdin/out/err...
r3800 from IPython.utils import io
Brian Granger
Work to address the review comments on Fernando's branch....
r2498
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------
def warn(msg,level=2,exit_val=1):
"""Standard warning printer. Gives formatting consistency.
MinRK
io.Term.cin/out/err replaced by io.stdin/out/err...
r3800 Output is sent to io.stderr (sys.stderr by default).
Brian Granger
Work to address the review comments on Fernando's branch....
r2498
Options:
-level(2): allows finer control:
0 -> Do nothing, dummy function.
1 -> Print message.
2 -> Print 'WARNING:' + message. (Default level).
3 -> Print 'ERROR:' + message.
4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val).
-exit_val (1): exit value returned by sys.exit() for a level 4
warning. Ignored for all other levels."""
if level>0:
header = ['','','WARNING: ','ERROR: ','FATAL ERROR: ']
Thomas Kluyver
Fix IPython.utils.warn API so messages are automatically displayed followed by a newline.
r8223 print(header[level], msg, sep='', file=io.stderr)
Brian Granger
Work to address the review comments on Fernando's branch....
r2498 if level == 4:
Matthias BUSSONNIER
use print function in module with `print >>`
r7817 print('Exiting.\n', file=io.stderr)
Brian Granger
Work to address the review comments on Fernando's branch....
r2498 sys.exit(exit_val)
def info(msg):
"""Equivalent to warn(msg,level=1)."""
warn(msg,level=1)
def error(msg):
"""Equivalent to warn(msg,level=3)."""
warn(msg,level=3)
def fatal(msg,exit_val=1):
"""Equivalent to warn(msg,exit_val=exit_val,level=4)."""
warn(msg,exit_val=exit_val,level=4)
Jonathan Frederic
Renamed *Widget to *,...
r17598
def DeprecatedClass(base, class_name):
# Hook the init method of the base class.
def init_hook(self, *pargs, **kwargs):
base.__init__(self, *pargs, **kwargs)
# Warn once per class.
if base not in DeprecatedClass._warned_classes:
DeprecatedClass._warned_classes.append(base)
warn('"{}" is deprecated, please use "{}" instead.'.format(
class_name, base.__name__))
return type(class_name, (base,), {'__init__': init_hook})
DeprecatedClass._warned_classes = []