Exemplo n.º 1
0
 def start_service(self):
     from IPython.frontend.html.notebook.notebookapp import NotebookApp
     app = NotebookApp()
     notebook_path = os.path.expanduser('~/.notizblock')
     if not os.path.exists(notebook_path):
         os.mkdir(notebook_path)
     nbdir = '--notebook-dir=%s' % notebook_path
     nb_argv = ['notebook', '--pylab=inline', '--no-browser', '--parent=True', nbdir]
     app.initialize(argv=nb_argv)
     self._host = app.ip
     self._port = app.port
     ip_process = Process(target=_ip_process_func, args=(app,))
     self._ip_process = ip_process
     ip_process.start()
Exemplo n.º 2
0
def run_lab():
    """
    Runs the html notebook.
    """
    print "Starting Web GUI: Open your web browser at http://localhost:8888/"
    print "Press CTRL+C to kill it"
    print
    from IPython.frontend.html.notebook.notebookapp import NotebookApp
    app = NotebookApp()
    # This option enables Matplotlib:
    app.initialize(["--pylab=inline"])
    app.start()
Exemplo n.º 3
0
    def ipython_notebook(self):
        # analogous to the calls in the django.core shell command
        from IPython.frontend.html.notebook.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]))
        # 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
Exemplo n.º 4
0
    def handle(self, addrport=None, *args, **options):
        if args:
            raise CommandError('Usage is notebook %s' % self.args)

        if addrport:
            if ':' in addrport:
                ip_addr, port = addrport.split(':')
            else:
                ip_addr = '127.0.0.1'
                port = addrport

        app = NotebookApp.instance()

        if 'ip_addr' in locals() and 'port' in locals():
            app.ip = ip_addr
            app.port = int(port)

        if options.get('no_mathjax', False):
            app.enable_mathjax = False
            del options['no_mathjax']

        app.initialize()
        app.start()
Exemplo n.º 5
0
    def handle(self, addrport=None, *args, **options):
        if args:
            raise CommandError('Usage is notebook %s' % self.args)

        if addrport:
            if ':' in addrport:
                ip_addr, port = addrport.split(':')
            else:
                ip_addr = '127.0.0.1'
                port = addrport

        app = NotebookApp.instance()

        if 'ip_addr' in locals() and 'port' in locals():
            app.ip = ip_addr
            app.port = int(port)

        if options.get('no_mathjax', False):
            app.enable_mathjax = False
            del options['no_mathjax']

        app.initialize()
        app.start()
Exemplo n.º 6
0
def main():
    from IPython.frontend.html.notebook.notebookapp import NotebookApp
    app = NotebookApp()
    app.initialize()
    app.start()