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 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 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 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 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 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 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: # 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 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 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()
def run_notebook(): app = NotebookApp.instance() ipython_arguments = getattr(settings, 'IPYTHON_ARGUMENTS', ['--ext', 'django_extensions.management.notebook_extension']) app.initialize(ipython_arguments) app.start()