コード例 #1
0
ファイル: utils.py プロジェクト: renjithmadhavan/jupyterlab
 def start_thread():
     app = cls.notebook = LabApp(
         app_dir=lab_dir,
         port=cls.port,
         user_settings_dir=lab_settings,
         workspaces_dir=lab_workspaces,
         port_retries=0,
         open_browser=False,
         config_dir=cls.config_dir,
         data_dir=cls.data_dir,
         runtime_dir=cls.runtime_dir,
         notebook_dir=cls.notebook_dir,
         base_url=cls.url_prefix,
         config=config,
         allow_root=True,
         token=cls.token,
     )
     # don't register signal handler during tests
     app.init_signal = lambda: None
     # clear log handlers and propagate to root for nose to capture it
     # needs to be redone after initialize, which reconfigures logging
     app.log.propagate = True
     app.log.handlers = []
     app.initialize(argv=[])
     app.log.propagate = True
     app.log.handlers = []
     loop = IOLoop.current()
     loop.add_callback(started.set)
     try:
         app.start()
     finally:
         # set the event, so failure to start doesn't cause a hang
         started.set()
         app.session_manager.close()
コード例 #2
0
ファイル: start_server.py プロジェクト: QPanWeb/APP-orchest
def main():
    # Add default options.
    # TODO: don't allow to run as root. But to make that work, the
    #       docker image has to be changed in order to allow another
    #       user. For now, it just works.
    formatted_args = [
        '--allow-root',
        '--no-browser',
        '--debug',
        '--ip=0.0.0.0',
        '--port=8888',
    ]

    sys.argv.extend(formatted_args)

    # Initializes the Lab instance and writes its server info to a json
    # file that can be accessed outside of the subprocess in order to
    # connect to the started server.
    la = LabApp()
    la.initialize()

    _write_server_info_to_file(la.server_info(), 'server_info.json')

    # This print is mandatory. The message can be changed, but the
    # subprocess is piping this output to stdout to confirm that
    # the JupyterLab has successfully started.
    print('Initialized JupyterLab instance')

    # TODO: if the starting takes too long, then the front-end will
    #       already try to connect to the lab instance. Resulting in an
    #       error. This should obviously be more robust.
    la.start()
コード例 #3
0
 def app_init(*args, **kwargs):
     app = LabApp.instance()
     app.initialize(*args, **kwargs)
     return app
コード例 #4
0
 def run_jupyterlab():
     app = LabApp.instance()
     self.run_notebookapp(app, options)
コード例 #5
0
    def launch(self, argv=None, **kwargs):
        from jupyterlab.labapp import LabApp

        app = LabApp()
        app.launch_instance(argv=argv, **kwargs)
コード例 #6
0
# Set PYTHONPATH so kernel_launcher can run in the right env
os.environ['PYTHONPATH'] = os.pathsep.join(sys.path)

# Init the Jupyter app

kwargs = {}
argv = ['--no-browser']

jupyterlab = False
if len(sys.argv) > 1:
    jupyterlab = sys.argv[1] == 'lab'

if jupyterlab:
    from jupyterlab.labapp import LabApp
    app = LabApp.instance(**kwargs)
else:
    from notebook.notebookapp import NotebookApp
    app = NotebookApp.instance(**kwargs)

# import logging
# app.log_level = logging.DEBUG

app.initialize(argv)

with stdoutlock:
    print(json.dumps({'sys.path': sys.path}))
    print(json.dumps({'sys.executable': sys.executable}))
    print(json.dumps({'os.environ': dict(os.environ)}))

    print(json.dumps({'server_info': app.server_info()}))