コード例 #1
0
 def __call__(self, args):
     kwargs = {}
     try:
         # IPython 1.0+
         from IPython.html.notebookapp import NotebookApp
     except ImportError:
         # pre-IPython v1.0
         from IPython.frontend.html.notebook.notebookapp import NotebookApp
     print("You must choose a password so that others cannot connect to " \
           "your notebook.")
     pw = ytcfg.get("yt", "notebook_password")
     if len(pw) == 0 and not args.no_password:
         import IPython.lib
         pw = IPython.lib.passwd()
         print("If you would like to use this password in the future,")
         print("place a line like this inside the [yt] section in your")
         print("yt configuration file at ~/.yt/config")
         print()
         print("notebook_password = %s" % pw)
         print()
     elif args.no_password:
         pw = None
     if args.port != 0:
         kwargs['port'] = int(args.port)
     if args.profile is not None:
         kwargs['profile'] = args.profile
     if pw is not None:
         kwargs['password'] = pw
     app = NotebookApp(open_browser=args.open_browser, **kwargs)
     app.initialize(argv=[])
     print()
     print(
         "***************************************************************")
     print()
     print("The notebook is now live at:")
     print()
     print("     http://127.0.0.1:%s/" % app.port)
     print()
     print("Recall you can create a new SSH tunnel dynamically by pressing")
     print("~C and then typing -L%s:localhost:%s" % (app.port, app.port))
     print("where the first number is the port on your local machine. ")
     print()
     print("If you are using %s on your machine already, try " \
           "-L8889:localhost:%s" % (app.port, app.port))
     print()
     print(
         "***************************************************************")
     print()
     app.start()
コード例 #2
0
def n_action(option, opt_str, value, parser):
    args = [arg for arg in sys.argv[1:] if arg != opt_str]
    options, args = parser.parse_args(args)
    from IPython.html.notebookapp import NotebookApp
    sys.argv = ['notebook']
    NotebookApp.ipython_dir = param.resolve_path('platform/ipython',
                                                 path_to_file=False)
    NotebookApp.profile = 'topo'
    if options.IP is not None:
        NotebookApp.ip = options.IP
    if options.Port is not None:
        NotebookApp.port = options.Port
    NotebookApp().launch_instance()
    global something_executed
    something_executed = True
コード例 #3
0
if __name__ == '__main__':
    # create empty file
    with open('source/config/options/generated', 'w'):
        pass

    write_doc('terminal', 'Terminal IPython options',
              TerminalIPythonApp().classes)
    write_doc(
        'kernel',
        'IPython kernel options',
        kernel_classes,
        preamble=
        "These options can be used in :file:`ipython_notebook_config.py` "
        "or in :file:`ipython_qtconsole_config.py`")
    nbclasses = set(NotebookApp().classes) - set(kernel_classes)
    write_doc('notebook',
              'IPython notebook options',
              nbclasses,
              preamble="Any of the :doc:`kernel` can also be used.")

    try:
        from IPython.qt.console.qtconsoleapp import IPythonQtConsoleApp
    except ImportError:
        print("WARNING: Could not import qtconsoleapp. Config options for the "
              "Qt Console will not be documented.")
    else:
        qtclasses = set(IPythonQtConsoleApp().classes) - set(kernel_classes)
        write_doc('qtconsole',
                  'IPython Qt console options',
                  qtclasses,
コード例 #4
0
ファイル: autogen_config.py プロジェクト: wguo123/ipython
if __name__ == '__main__':
    # create empty file
    with open('source/config/options/generated', 'w'):
        pass

    write_doc('terminal', 'Terminal IPython options',
              TerminalIPythonApp().classes)
    write_doc(
        'kernel',
        'IPython kernel options',
        kernel_classes,
        preamble=
        "These options can be used in :file:`ipython_kernel_config.py`",
    )
    write_doc('notebook',
              'IPython notebook options',
              NotebookApp().classes,
              preamble="To configure the IPython kernel, see :doc:`kernel`.")

    try:
        from IPython.qt.console.qtconsoleapp import IPythonQtConsoleApp
    except ImportError:
        print("WARNING: Could not import qtconsoleapp. Config options for the "
              "Qt Console will not be documented.")
    else:
        write_doc(
            'qtconsole',
            'IPython Qt console options',
            IPythonQtConsoleApp().classes,
            preamble="To configure the IPython kernel, see :doc:`kernel`.")