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()
def run_notebook(): app = NotebookApp.instance() ipython_arguments = getattr(settings, 'IPYTHON_ARGUMENTS', [ '--ext', 'django_extensions.management.notebook_extension' ]) app.initialize(ipython_arguments) app.start()
def run_notebook(): app = NotebookApp.instance() # Treat IPYTHON_ARGUMENTS from settings ipython_arguments = getattr(settings, 'IPYTHON_ARGUMENTS', []) if 'django_extensions.management.notebook_extension' not in ipython_arguments: ipython_arguments.extend([ '--ext', 'django_extensions.management.notebook_extension' ]) # Treat NOTEBOOK_ARGUMENTS from settings notebook_arguments = getattr(settings, 'NOTEBOOK_ARGUMENTS', []) if no_browser and '--no-browser' not in notebook_arguments: notebook_arguments.append('--no-browser') if '--notebook-dir' not in notebook_arguments: notebook_arguments.extend(['--notebook-dir', '.']) # IPython < 3 passes through kernel args from notebook CLI if release.version_info[0] < 3: notebook_arguments.extend(ipython_arguments) app.initialize(notebook_arguments) # IPython >= 3 uses kernelspecs to specify kernel CLI args if release.version_info[0] >= 3: display_name = getattr(settings, 'IPYTHON_KERNEL_DISPLAY_NAME', "Django Shell-Plus") install_kernel_spec(app, display_name, ipython_arguments) app.start()
def run_notebook(): app = NotebookApp.instance() # Treat IPYTHON_ARGUMENTS from settings ipython_arguments = getattr(settings, 'IPYTHON_ARGUMENTS', []) if 'django_extensions.management.notebook_extension' not in ipython_arguments: ipython_arguments.extend(['--ext', 'django_extensions.management.notebook_extension']) # Treat NOTEBOOK_ARGUMENTS from settings notebook_arguments = getattr(settings, 'NOTEBOOK_ARGUMENTS', []) if no_browser and '--no-browser' not in notebook_arguments: notebook_arguments.append('--no-browser') if '--notebook-dir' not in notebook_arguments: notebook_arguments.extend(['--notebook-dir', '.']) # IPython < 3 passes through kernel args from notebook CLI from IPython import release if release.version_info[0] < 3: notebook_arguments.extend(ipython_arguments) app.initialize(notebook_arguments) # IPython >= 3 uses kernelspecs to specify kernel CLI args if release.version_info[0] >= 3: display_name = getattr(settings, 'IPYTHON_KERNEL_DISPLAY_NAME', "Django Shell-Plus") install_kernel_spec(app, display_name, ipython_arguments) app.start()
def main(_): notebookapp = NotebookApp.instance() notebookapp.open_browser = False notebookapp.ip = "0.0.0.0" notebookapp.port = 8888 notebookapp.allow_origin_pat = "https://colab\\.[^.]+\\.google.com" notebookapp.allow_root = True notebookapp.token = "" notebookapp.disable_check_xsrf = True notebookapp.initialize() notebookapp.start()
def run_notebook(): from django.conf import settings try: from IPython.html.notebookapp import NotebookApp except ImportError: from IPython.frontend.html.notebook import notebookapp NotebookApp = notebookapp.NotebookApp app = NotebookApp.instance() ipython_arguments = getattr(settings, 'IPYTHON_ARGUMENTS', ['--ext', 'django_extensions.management.notebook_extension']) app.initialize(ipython_arguments) app.start()
def run_notebook(): from django.conf import settings try: from IPython.html.notebookapp import NotebookApp except ImportError: from IPython.frontend.html.notebook import notebookapp NotebookApp = notebookapp.NotebookApp app = NotebookApp.instance() ipython_arguments = getattr( settings, 'IPYTHON_ARGUMENTS', ['--ext', 'django_extensions.management.notebook_extension']) app.initialize(ipython_arguments) app.start()
def run_notebook(): app = NotebookApp.instance() ipython_arguments = getattr(settings, 'IPYTHON_ARGUMENTS', ['--ext', 'django_extensions.management.notebook_extension']) if 'django_extensions.management.notebook_extension' not in ipython_arguments: print(self.style.ERROR("""WARNING: IPython Notebook Extension 'django_extensions.management.notebook_extension' not found in IPYTHON_ARGUMENTS. Without it the IPython Notebook will not initialize Django and will not automatically load your models. Please read the documentation carefully: http://django-extensions.readthedocs.org/en/latest/shell_plus.html#configuration """)) app.initialize(ipython_arguments) app.start()
def ipython_notebook(self): """ Create the notebook app, after having patched PYTHONPATH. """ # If manage.py modified sys.path, we need that, because of # https://github.com/ipython/ipython/issues/5420#issuecomment-38503775 os.environ['PYTHONPATH'] = ':'.join(sys.path) # analogous to the calls in the django.core shell command from IPython.html.notebookapp import NotebookApp app = NotebookApp.instance() app.initialize(argv=self._argv[1:]) app.start()
def main(unused_argv): sys.argv = ORIG_ARGV if not IS_KERNEL: # Drop all flags. sys.argv = [sys.argv[0]] # NOTE(sadovsky): For some reason, putting this import at the top level # breaks inline plotting. It's probably a bug in the stone-age version of # matplotlib. from IPython.html.notebookapp import NotebookApp # pylint: disable=g-import-not-at-top notebookapp = NotebookApp.instance() notebookapp.open_browser = True # password functionality adopted from quality/ranklab/main/tools/notebook.py # add options to run with "password" if FLAGS.password: from IPython.lib import passwd # pylint: disable=g-import-not-at-top notebookapp.ip = "0.0.0.0" notebookapp.password = passwd(FLAGS.password) else: print( "\nNo password specified; Notebook server will only be available" " on the local machine.\n") notebookapp.initialize(argv=["--notebook-dir", FLAGS.notebook_dir]) if notebookapp.ip == "0.0.0.0": proto = "https" if notebookapp.certfile else "http" url = "%s://%s:%d%s" % (proto, socket.gethostname(), notebookapp.port, notebookapp.base_project_url) print("\nNotebook server will be publicly available at: %s\n" % url) notebookapp.start() return # Drop the --flagfile flag so that notebook doesn't complain about an # "unrecognized alias" when parsing sys.argv. sys.argv = ([sys.argv[0]] + [z for z in sys.argv[1:] if not z.startswith("--flagfile")]) from IPython.kernel.zmq.kernelapp import IPKernelApp # pylint: disable=g-import-not-at-top kernelapp = IPKernelApp.instance() kernelapp.initialize() # Enable inline plotting. Equivalent to running "%matplotlib inline". ipshell = kernelapp.shell ipshell.enable_matplotlib("inline") kernelapp.start()
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
def run_notebook(mainArgs): """Run the ipython notebook server""" from IPython.html.notebookapp import NotebookApp # from IPython.html.notebook import kernelmanager code = "" code += "from SimpleCV import *;" code += "init_options_handler.enable_notebook();" # kernelmanager.MappingKernelManager.first_beat = 30.0 app = NotebookApp.instance() mainArgs += ["--port", "5050", "--c", code] app.initialize(mainArgs) app.start() sys.exit()
def run_notebook(): app = NotebookApp.instance() ipython_arguments = getattr(settings, 'IPYTHON_ARGUMENTS', [ '--ext', 'django_extensions.management.notebook_extension' ]) if 'django_extensions.management.notebook_extension' not in ipython_arguments: print( self.style.ERROR("""WARNING: IPython Notebook Extension 'django_extensions.management.notebook_extension' not found in IPYTHON_ARGUMENTS. Without it the IPython Notebook will not initialize Django and will not automatically load your models. Please read the documentation carefully: http://django-extensions.readthedocs.org/en/latest/shell_plus.html#configuration """)) app.initialize(ipython_arguments) app.start()
def ipython_notebook(self): # analogous to the calls in the django.core shell command from IPython.html.notebookapp import NotebookApp app = NotebookApp.instance() app.initialize() # here sys.path contains, as the first element, the directory containing # manage.py. However, in the kernels that are started for the actual # notebooks, sys.path does not contain this project directory. looks # like this has been fixed in IPython, and should be out AFTER 0.13.2: # https://github.com/ipython/ipython/commit/463ab6b388436efdb8bb2f949817e94c74f51dee # until that time, after 0.13.2 is released, we need the following # os.environ modification before and restoration after app.start() # get current PYTHONPATH pps = os.environ.get('PYTHONPATH') if pps is None: # remember that there was no PYTHONPATH to start with nopp = True pps = '' else: nopp = False # break up into components ppl = pps.split(os.pathsep) # path containing manage.py project_path = os.path.abspath(os.path.dirname(sys.argv[0])) print(project_path) # add it ppl.append(project_path) # and set it os.environ['PYTHONPATH'] = os.pathsep.join(ppl) # start the notebook app.start() # user has quit the notebook, we restore the saved PYTHONPATH if nopp: # there was none to start with, so we delete it del os.environ['PYTHONPATH'] else: os.environ['PYTHONPATH'] = pps
def main(unused_argv): sys.argv = ORIG_ARGV if not IS_KERNEL: # Drop all flags. sys.argv = [sys.argv[0]] # NOTE(sadovsky): For some reason, putting this import at the top level # breaks inline plotting. It's probably a bug in the stone-age version of # matplotlib. from IPython.html.notebookapp import NotebookApp # pylint: disable=g-import-not-at-top notebookapp = NotebookApp.instance() notebookapp.open_browser = True # password functionality adopted from quality/ranklab/main/tools/notebook.py # add options to run with "password" if FLAGS.password: from IPython.lib import passwd # pylint: disable=g-import-not-at-top notebookapp.ip = "0.0.0.0" notebookapp.password = passwd(FLAGS.password) else: print("\nNo password specified; Notebook server will only be available" " on the local machine.\n") notebookapp.initialize(argv=["--notebook-dir", FLAGS.notebook_dir]) if notebookapp.ip == "0.0.0.0": proto = "https" if notebookapp.certfile else "http" url = "%s://%s:%d%s" % (proto, socket.gethostname(), notebookapp.port, notebookapp.base_project_url) print("\nNotebook server will be publicly available at: %s\n" % url) notebookapp.start() return # Drop the --flagfile flag so that notebook doesn't complain about an # "unrecognized alias" when parsing sys.argv. sys.argv = ([sys.argv[0]] + [z for z in sys.argv[1:] if not z.startswith("--flagfile")]) from IPython.kernel.zmq.kernelapp import IPKernelApp # pylint: disable=g-import-not-at-top kernelapp = IPKernelApp.instance() kernelapp.initialize() # Enable inline plotting. Equivalent to running "%matplotlib inline". ipshell = kernelapp.shell ipshell.enable_matplotlib("inline") kernelapp.start()
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()
def run_notebook(mainArgs): """Run the ipython notebook server""" from IPython.html.notebookapp import NotebookApp #from IPython.html.notebook import kernelmanager code = "" code += "from SimpleCV import *;" code += "init_options_handler.enable_notebook();" #kernelmanager.MappingKernelManager.first_beat = 30.0 app = NotebookApp.instance() mainArgs += [ '--port', '5050', '--c', code, ] app.initialize(mainArgs) app.start() sys.exit()
def main(unused_argv): sys.argv = ORIG_ARGV if not IS_KERNEL: sys.argv = [sys.argv[0]] from IPython.html.notebookapp import NotebookApp notebookapp = NotebookApp.instance() notebookapp.open_browser = True if FLAGS.password: from IPython.lib import passwd notebook.ip = "0.0.0.0" notebook.password = passwd(FLAGS.password) else: print( "\nNo password specified: Notebook server will only be available" " on the local machine.\n") notebookapp.initialize(argv=["--notebook-dir", FLAGS.notebook_dir]) if notebookapp.ip == "0.0.0.0": proto = "https" if notebookapp.certfile else "http" url = "%s://%s:%d%s" % (proto, socket.gethostname(), notebookapp.port, notebookapp.base_project_url) print("\nNotebook server will be publicly available at: %s\n" % url) notebookapp.start() return sys.argv = ([sys.argv[0]] + [z for z in sys.argv[1:] if not z.startswith("--flagfile")]) from IPython.kernel.zmq.kernelapp import IPKernelApp kernelapp = IPKernelApp.instance() kernelapp.initialize() ipshell = kernelapp.shell ipshell.enable_matplotlib("inline") kernelapp.start()
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`.")
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,
def run_notebook(): app = NotebookApp.instance() ipython_arguments = getattr(settings, 'IPYTHON_ARGUMENTS', ['--ext', 'django_extensions.management.notebook_extension']) app.initialize(ipython_arguments) app.start()