Пример #1
0
 def _data_dir_default(self):
     app = None
     try:
         if JupyterApp.initialized():
             app = JupyterApp.instance()
     except MultipleInstanceError:
         pass
     if app is None:
         # create an app, without the global instance
         app = JupyterApp()
         app.initialize(argv=[])
     return app.data_dir
Пример #2
0
def jupyter_app(caplog):
    """Initialized (but unlaunched) Jupyter app."""
    app = JupyterApp.instance()
    app.log.addHandler(caplog.handler)
    yield app
    app.log.removeHandler(caplog.handler)
    app.clear_instance()
Пример #3
0
 def setup_server_config(self, EXT_CONFIG):
     # Set the server extension to launch on startup by modifying the
     # jupyter_notebook_config.py
     CONFIG = os.path.join(jupyter_config_dir(), 'jupyter_config.py')
     ensure_dir_exists(jupyter_config_dir())
     if os.path.isfile(CONFIG):
         pass
     else:
         c = JupyterApp()
         c.write_default_config()
     with open(CONFIG, 'r+') as fh:
         lines = fh.read()
         for i in EXT_CONFIG:
             if i not in lines:
                 fh.seek(0, 2)
                 fh.write('\n')
                 fh.write(i)
     print("OUTCOME: Added the Stepsize server extension "
           "configuration to the jupyter_config.py")
Пример #4
0
 def setup_server_config(self, EXT_CONFIG):
     # Set the server extension to launch on startup by modifying the
     # jupyter_notebook_config.py
     CONFIG = os.path.join(jupyter_config_dir(), 'jupyter_config.py')
     ensure_dir_exists(jupyter_config_dir())
     if os.path.isfile(CONFIG):
         pass
     else:
         c = JupyterApp()
         c.write_default_config()
     with open(CONFIG, 'r+') as fh:
         lines = fh.read()
         for i in EXT_CONFIG:
             if i not in lines:
                 fh.seek(0, 2)
                 fh.write('\n')
                 fh.write(i)
     print("OUTCOME: Added the Stepsize server extension "
           "configuration to the jupyter_config.py")
Пример #5
0
 def _data_dir_default(self):
     app = None
     try:
         if JupyterApp.initialized():
             app = JupyterApp.instance()
     except MultipleInstanceError:
         pass
     if app is None:
         # create an app, without the global instance
         app = JupyterApp()
         app.initialize(argv=[])
     return app.data_dir
Пример #6
0
 def initialize(self, argv=[]):
     JupyterApp.initialize(self, argv=argv)
     self.init_connection_file()
Пример #7
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()
Пример #8
0
def test_default_traits():
    app = JupyterApp()
    for trait_name in app.traits():
        value = getattr(app, trait_name)
Пример #9
0
def test_default_traits():
    app = JupyterApp()
    for trait_name in app.traits():
        value = getattr(app, trait_name)
Пример #10
0
def test_basic():
    app = JupyterApp()
Пример #11
0
 def initialize(self, argv=[]):
     JupyterApp.initialize(self, argv=argv)
     self.init_connection_file()
Пример #12
0
 def start(self):
     # JupyterApp.start dispatches on NoStart
     JupyterApp.start(self)
     super(ZMQTerminalIPythonApp, self).start()
Пример #13
0
def test_basic():
    JupyterApp()
Пример #14
0
 def initialize(self, argv=None):
     JupyterApp.initialize(self, argv=argv or [])
     self.init_connection_file()