How to use the jupyterlab.commands.get_app_dir function in jupyterlab

To help you get started, we’ve selected a few jupyterlab examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterlab / jupyterlab / jupyterlab / labapp.py View on Github external
def start(self):
        print('Application directory:   %s' % get_app_dir())
        print('User Settings directory: %s' % get_user_settings_dir())
        print('Workspaces directory: %s' % get_workspaces_dir())
github jupyterlab / jupyterlab / jupyterlab / labapp.py View on Github external
"""

    aliases = lab_aliases
    flags = lab_flags

    subcommands = dict(
        build=(LabBuildApp, LabBuildApp.description.splitlines()[0]),
        clean=(LabCleanApp, LabCleanApp.description.splitlines()[0]),
        path=(LabPathApp, LabPathApp.description.splitlines()[0]),
        paths=(LabPathApp, LabPathApp.description.splitlines()[0])
    )

    default_url = Unicode('/lab', config=True,
        help="The default URL to redirect to from `/`")

    app_dir = Unicode(get_app_dir(), config=True,
        help="The app directory to launch JupyterLab from.")

    user_settings_dir = Unicode(get_user_settings_dir(), config=True,
        help="The directory for user settings.")

    workspaces_dir = Unicode(get_workspaces_dir(), config=True,
        help="The directory for workspaces")

    core_mode = Bool(False, config=True,
        help="""Whether to start the app in core mode. In this mode, JupyterLab
        will run using the JavaScript assets that are within the installed
        JupyterLab Python package. In core mode, third party extensions are disabled.
        The `--dev-mode` flag is an alias to this to be used when the Python package
        itself is installed in development mode (`pip install -e .`).
        """)
github jupyterlab / jupyterlab / jupyterlab / extension.py View on Github external
"""Load the JupyterLab server extension.
    """
    # Delay imports to speed up jlpmapp
    from jupyterlab_launcher import add_handlers, LabConfig
    from notebook.utils import url_path_join as ujoin, url_escape
    from tornado.ioloop import IOLoop
    from .build_handler import build_path, Builder, BuildHandler
    from .commands import (
        get_app_dir, get_user_settings_dir, watch, ensure_dev, watch_dev,
        pjoin, DEV_DIR, HERE, get_app_info, ensure_core, get_workspaces_dir
    )

    web_app = nbapp.web_app
    logger = nbapp.log
    config = LabConfig()
    app_dir = getattr(nbapp, 'app_dir', get_app_dir())
    user_settings_dir = getattr(
        nbapp, 'user_settings_dir', get_user_settings_dir()
    )
    workspaces_dir = getattr(
        nbapp, 'workspaces_dir', get_workspaces_dir()
    )

    # Print messages.
    logger.info('JupyterLab beta preview extension loaded from %s' % HERE)
    logger.info('JupyterLab application directory is %s' % app_dir)

    config.app_name = 'JupyterLab Beta'
    config.app_namespace = 'jupyterlab'
    config.page_url = '/lab'
    config.cache_files = True
github krassowski / jupyterlab-lsp / py_src / jupyter_lsp / types.py View on Github external
""" get the "usual suspects" for where `node_modules` may be found

        - where this was launch (usually the same as NotebookApp.notebook_dir)
        - the JupyterLab staging folder (if available)
        - wherever conda puts it
        - wherever some other conventions put it
        """

        # check where the server was started first
        roots = [pathlib.Path.cwd()]

        # try jupyterlab staging next
        try:
            from jupyterlab import commands

            roots += [pathlib.Path(commands.get_app_dir()) / "staging"]
        except ImportError:  # pragma: no cover
            pass

        # conda puts stuff in $PREFIX/lib on POSIX systems
        roots += [pathlib.Path(sys.prefix) / "lib"]

        # ... but right in %PREFIX% on nt
        roots += [pathlib.Path(sys.prefix)]

        return roots
github vpython / vpython-jupyter / vpython / with_notebook.py View on Github external
nbdata = nbdir+'vpython_data'
nblib = nbdir+'vpython_libraries'
transfer = True # need to transfer files from site-packages to nbextensions

### If JupyterLab is installed then copy vpython_data directory to static dir in Jupytarlab Application Directory
try:
	import jupyterlab
	import jupyterlab.commands
except ImportError:
	#logging.info("Unable to import jupyterlab")
	pass
else:
    # We have jupyterlab, is it the right version?
    if jupyterlab.__version__ >= '0.35.0':
        from os.path import join
        labextensions_dir = join(jupyterlab.commands.get_app_dir(), u'static')
        notebook.nbextensions.install_nbextension(path=package_dir + "/vpython_data",
                                                  nbextensions_dir=labextensions_dir,
                                                  overwrite=False,
                                                  verbose=0)

if 'nbextensions' in os.listdir(jd):
    ldir = os.listdir(nbdir)
    if ('vpython_data' in ldir and len(os.listdir(nbdata)) == datacnt and
       'vpython_libraries' in ldir and len(os.listdir(nblib)) == libcnt and
        'vpython_version.txt' in ldir):
        v = open(nbdir+'/vpython_version.txt').read()
        transfer = (v != __version__) # need not transfer files to nbextensions if correct version's files already there

if transfer:
    notebook.nbextensions.install_nbextension(path = package_dir+"/vpython_data",overwrite = True,user = True,verbose = 0)
    notebook.nbextensions.install_nbextension(path = package_dir+"/vpython_libraries",overwrite = True,user = True,verbose = 0)
github krassowski / jupyterlab-lsp / py_src / jupyter_lsp / server.py View on Github external
def _default_node_roots(self):
        """ get the "usual suspects" for where node_modules may be found

        - where this was launch (usually the same as NotebookApp.notebook_dir)
        - the JupyterLab staging folder
        - wherever conda puts it
        - wherever some other conventions put it
        """
        return [
            os.getcwd(),
            pathlib.Path(get_app_dir()) / "staging",
            pathlib.Path(sys.prefix) / "lib",
            # TODO: "well-known" windows paths
            sys.prefix,
        ]