Example #1
0
                                            cwd=self.working_directory).pid

        print('Jupyter Notebook started with pid: ', self.jupyter_pid)
        return self.jupyter_pid

    def stop(self):
        if self.jupyter_pid is not None:
            print('Stopping Jupyter Notebook process ... pid:',
                  self.jupyter_pid)
            os.kill(self.jupyter_pid, signal.SIGINT)  # or signal.SIGKILL
            self.jupyter_pid = None


if __name__ == '__main__':
    from jupyter_core.application import JupyterApp
    # from IPython.terminal.ipapp import launch_new_instance
    # from IPython.lib import passwd
    from socket import gethostname
    import warnings

    warnings.filterwarnings("ignore", module="zmq.*")
    sys.argv.append("notebook")
    sys.argv.append("--IPKernelApp.pylab='inline'")
    sys.argv.append("--NotebookApp.ip=" + gethostname())
    sys.argv.append("--NotebookApp.open_browser=False")
    # sys.argv.append("--NotebookApp.password=" + passwd())
    # launch_new_instance()

    app = JupyterApp()
    app.launch_instance()