当前位置: 首页>>代码示例>>Python>>正文


Python utils.url_path_join方法代码示例

本文整理汇总了Python中notebook.utils.url_path_join方法的典型用法代码示例。如果您正苦于以下问题:Python utils.url_path_join方法的具体用法?Python utils.url_path_join怎么用?Python utils.url_path_join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在notebook.utils的用法示例。


在下文中一共展示了utils.url_path_join方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_jupyter_server_extension

# 需要导入模块: from notebook import utils [as 别名]
# 或者: from notebook.utils import url_path_join [as 别名]
def load_jupyter_server_extension(nb_server_app):
    """
    Called when the extension is loaded.

    Args:
        nb_server_app (NotebookApp): handle to the Notebook webserver instance.
    """
    web_app = nb_server_app.web_app
    # Prepend the base_url so that it works in a jupyterhub setting
    base_url = web_app.settings['base_url']
    latex = url_path_join(base_url, 'latex')
    build = url_path_join(latex, 'build')
    synctex = url_path_join(latex, 'synctex')

    handlers = [(f'{build}{path_regex}',
                 LatexBuildHandler,
                 {"notebook_dir": nb_server_app.notebook_dir}
                ),
                (f'{synctex}{path_regex}',
                 LatexSynctexHandler,
                 {"notebook_dir": nb_server_app.notebook_dir}
                 )]
    web_app.add_handlers('.*$', handlers) 
开发者ID:jupyterlab,项目名称:jupyterlab-latex,代码行数:25,代码来源:__init__.py

示例2: load_jupyter_server_extension

# 需要导入模块: from notebook import utils [as 别名]
# 或者: from notebook.utils import url_path_join [as 别名]
def load_jupyter_server_extension(nb_server_app):
    """
    Called when the extension is loaded.

    Args:
        nb_server_app (NotebookWebApplication): handle to the Notebook webserver instance.
    """
    web_app = nb_server_app.web_app
    base_url = web_app.settings['base_url']
    host_pattern = '.*$'

    if not isinstance(nb_server_app.contents_manager, MetaManager):
        warnings.warn(_mc_config_warning_msg)
        return

    # init managers from resources described in notebook server config
    nb_server_app.contents_manager.initResource(
        *nb_server_app.config.get('jupyterfs', {}).get('specs', [])
    )

    resources_url = 'jupyterfs/resources'
    print('Installing jupyter-fs resources handler on path %s' % url_path_join(base_url, resources_url))
    web_app.add_handlers(host_pattern, [(url_path_join(base_url, resources_url), MetaManagerHandler)]) 
开发者ID:jpmorganchase,项目名称:jupyter-fs,代码行数:25,代码来源:extension.py

示例3: load_jupyter_server_extension

# 需要导入模块: from notebook import utils [as 别名]
# 或者: from notebook.utils import url_path_join [as 别名]
def load_jupyter_server_extension(nb_server_app):
    """
    Called when the extension is loaded.

    Args:
        nb_server_app (NotebookWebApplication): handle to the Notebook webserver instance.
    """
    web_app = nb_server_app.web_app
    commands = nb_server_app.config.get('JupyterLabCommands', {}).get('commands', {})

    base_url = web_app.settings['base_url']

    host_pattern = '.*$'
    print('Installing jupyterlab_commands handler on path %s' % url_path_join(base_url, 'commands'))

    print('Available commands: %s' % ','.join(k for k in commands))
    web_app.add_handlers(host_pattern, [(url_path_join(base_url, 'commands/get'), CommandsListHandler, {'commands': commands})])
    web_app.add_handlers(host_pattern, [(url_path_join(base_url, 'commands/run'), CommandsHandler, {'commands': commands})]) 
开发者ID:timkpaine,项目名称:jupyterlab_commands,代码行数:20,代码来源:extension.py

示例4: load_jupyter_server_extension

# 需要导入模块: from notebook import utils [as 别名]
# 或者: from notebook.utils import url_path_join [as 别名]
def load_jupyter_server_extension(nb_server_app):
  """Called by Jupyter when starting the notebook manager."""
  # We only want to import these modules when setting up a server extension, and
  # want to avoid raising an exception when the `notebook` package isn't
  # available.
  # pylint: disable=g-import-not-at-top
  from notebook import utils
  from google.colab._serverextension import _handlers
  # pylint: enable=g-import-not-at-top

  nb_server_app.log.addFilter(_ColabLoggingFilter())
  app = nb_server_app.web_app

  url_maker = lambda path: utils.url_path_join(app.settings['base_url'], path)
  monitor_relative_path = '/api/colab/resources'

  app.add_handlers('.*$', [
      (url_maker(monitor_relative_path), _handlers.ResourceUsageHandler, {
          'kernel_manager': app.settings['kernel_manager']
      }),
      (url_maker('/api/colab/drive'), _handlers.DriveHandler),
  ])
  nb_server_app.log.info('google.colab serverextension initialized.') 
开发者ID:googlecolab,项目名称:colabtools,代码行数:25,代码来源:__init__.py

示例5: _load_jupyter_server_extension

# 需要导入模块: from notebook import utils [as 别名]
# 或者: from notebook.utils import url_path_join [as 别名]
def _load_jupyter_server_extension(nb_server_app):
    """
    Called when the extension is loaded.

    Args:
        nb_server_app (NotebookWebApplication): handle to the Notebook webserver instance.
    """
    web_app = nb_server_app.web_app

    host_pattern = '.*$'
    base_url = web_app.settings['base_url']
    # host_pattern = '.*$'
    print('Installing nbcelltests handler on path %s' % url_path_join(base_url, 'celltests'))

    rules = nb_server_app.config.get('JupyterLabCelltests', {}).get('rules', {})
    test_executable = nb_server_app.config.get('JupyterLabCelltests', {}).get('test_executable', [sys.executable, '-m', 'pytest', '-v'])
    lint_executable = nb_server_app.config.get('JupyterLabCelltests', {}).get('lint_executable', [sys.executable, '-m', 'flake8', '--ignore=W391'])

    web_app.add_handlers(host_pattern, [(url_path_join(base_url, 'celltests/test/run'), RunCelltestsHandler, {'rules': rules, 'executable': test_executable})])
    web_app.add_handlers(host_pattern, [(url_path_join(base_url, 'celltests/lint/run'), RunLintsHandler, {'rules': rules, 'executable': lint_executable})]) 
开发者ID:jpmorganchase,项目名称:nbcelltests,代码行数:22,代码来源:extension.py

示例6: load_jupyter_server_extension

# 需要导入模块: from notebook import utils [as 别名]
# 或者: from notebook.utils import url_path_join [as 别名]
def load_jupyter_server_extension(nbapp):
    web_app = nbapp.web_app
    base_url = url_path_join(web_app.settings['base_url'], 'git-pull')
    handlers = [
        (url_path_join(base_url, 'api'), SyncHandler),
        (base_url, UIHandler),
        (url_path_join(web_app.settings['base_url'], 'git-sync'), LegacyGitSyncRedirectHandler),
        (url_path_join(web_app.settings['base_url'], 'interact'), LegacyInteractRedirectHandler),
        (
            url_path_join(base_url, 'static', '(.*)'),
            StaticFileHandler,
            {'path': os.path.join(os.path.dirname(__file__), 'static')}
        )
    ]
    web_app.settings['nbapp'] = nbapp
    web_app.add_handlers('.*', handlers) 
开发者ID:jupyterhub,项目名称:nbgitpuller,代码行数:18,代码来源:__init__.py

示例7: get

# 需要导入模块: from notebook import utils [as 别名]
# 或者: from notebook.utils import url_path_join [as 别名]
def get(self, action):
        example_id = self.get_argument('example_id')
        if action == 'preview':
            self.finish(self.manager.preview_example(example_id))
        elif action == 'fetch':
            dest = self.get_argument('dest')
            dest = self.manager.fetch_example(example_id, dest)
            self.redirect(ujoin(self.base_url, 'notebooks', dest))
        elif action == 'fetchfile':
            dest = self.get_argument('dest')
            dest = self.manager.fetch_example(example_id, dest)
            self.finish(dest)



# -----------------------------------------------------------------------------
# URL to handler mappings
# ----------------------------------------------------------------------------- 
开发者ID:qtangs,项目名称:sagemaker-notebook-container,代码行数:20,代码来源:handlers.py

示例8: load_jupyter_server_extension

# 需要导入模块: from notebook import utils [as 别名]
# 或者: from notebook.utils import url_path_join [as 别名]
def load_jupyter_server_extension(nb_server_app):
    """
    Called when the extension is loaded.

    Args:
        nb_server_app (NotebookWebApplication):
        handle to the Notebook webserver instance.
    """
    web_app = nb_server_app.web_app
    base_url = web_app.settings["base_url"]
    endpoint = url_path_join(base_url, "s3")
    handlers = [
        (url_path_join(endpoint, "auth") + "(.*)", AuthHandler),
        (url_path_join(endpoint, "files") + "(.*)", S3Handler),
    ]
    web_app.add_handlers(".*$", handlers) 
开发者ID:IBM,项目名称:jupyterlab-s3-browser,代码行数:18,代码来源:__init__.py

示例9: load_jupyter_server_extension

# 需要导入模块: from notebook import utils [as 别名]
# 或者: from notebook.utils import url_path_join [as 别名]
def load_jupyter_server_extension(nb_server_app):
    web_app = nb_server_app.web_app
    host_pattern = '.*$'
    web_app.add_handlers(host_pattern, [
        (url_path_join(web_app.settings['base_url'], r'/elyra/{}'.format(YamlSpecHandler.get_resource_metadata()[0])),
         YamlSpecHandler),
        (url_path_join(web_app.settings['base_url'], r'/elyra/metadata/%s' % (namespace_regex)), MetadataHandler),
        (url_path_join(web_app.settings['base_url'], r'/elyra/metadata/%s/%s' % (namespace_regex, resource_regex)),
         MetadataResourceHandler),
        (url_path_join(web_app.settings['base_url'], r'/elyra/schema/%s' % (namespace_regex)), SchemaHandler),
        (url_path_join(web_app.settings['base_url'], r'/elyra/schema/%s/%s' % (namespace_regex, resource_regex)),
         SchemaResourceHandler),
        (url_path_join(web_app.settings['base_url'], r'/elyra/namespace'), NamespaceHandler),
        (url_path_join(web_app.settings['base_url'], r'/elyra/pipeline/schedule'), PipelineSchedulerHandler),
        (url_path_join(web_app.settings['base_url'], r'/elyra/pipeline/export'), PipelineExportHandler),
    ])
    # Create PipelineProcessorManager instance passing root directory
    PipelineProcessorManager.instance(root_dir=web_app.settings['server_root_dir']) 
开发者ID:elyra-ai,项目名称:elyra,代码行数:20,代码来源:__init__.py

示例10: post

# 需要导入模块: from notebook import utils [as 别名]
# 或者: from notebook.utils import url_path_join [as 别名]
def post(self, namespace):

        namespace = url_unescape(namespace)
        try:
            instance = self._validate_body()
            self.log.debug("MetadataHandler: Creating metadata instance '{}' in namespace '{}'...".
                           format(instance.name, namespace))
            metadata_manager = MetadataManager(namespace=namespace)
            metadata = metadata_manager.add(instance.name, instance, replace=False)
        except (ValidationError, ValueError, SyntaxError) as err:
            raise web.HTTPError(400, str(err)) from err
        except FileNotFoundError as err:
            raise web.HTTPError(404, str(err)) from err
        except FileExistsError as err:
            raise web.HTTPError(409, str(err)) from err
        except Exception as err:
            raise web.HTTPError(500, repr(err)) from err

        self.set_status(201)
        self.set_header("Content-Type", 'application/json')
        location = url_path_join(self.base_url, 'elyra', 'metadata', namespace, metadata.name)
        self.set_header('Location', location)
        self.finish(metadata.to_dict(trim=True)) 
开发者ID:elyra-ai,项目名称:elyra,代码行数:25,代码来源:handlers.py

示例11: fetch

# 需要导入模块: from notebook import utils [as 别名]
# 或者: from notebook.utils import url_path_join [as 别名]
def fetch(request, *parts, **kwargs):
    # Handle URL strings

    # Since base_url is already escaped, unescape it.
    path = url_escape(url_path_join(*parts), plus=False)

    # Make request.
    method = 'GET'
    if 'method' in kwargs and kwargs['method']:
        method = kwargs['method']

    body = None
    if 'body' in kwargs and kwargs['body']:
        body = kwargs['body']

    return request(method, path, data=body)
# END - Remove once transition to jupyter_server occurs 
开发者ID:elyra-ai,项目名称:elyra,代码行数:19,代码来源:conftest.py

示例12: load_jupyter_server_extension

# 需要导入模块: from notebook import utils [as 别名]
# 或者: from notebook.utils import url_path_join [as 别名]
def load_jupyter_server_extension(nbapp):
    # Set up handlers picked up via config
    base_url = nbapp.web_app.settings['base_url']
    serverproxy = ServerProxy(parent=nbapp)

    server_processes = [make_server_process(k, v) for k, v in serverproxy.servers.items()]
    server_processes += get_entrypoint_server_processes()
    server_handlers = make_handlers(base_url, server_processes)
    nbapp.web_app.add_handlers('.*', server_handlers)

    # Set up default handler
    setup_handlers(nbapp.web_app, serverproxy.host_whitelist)

    launcher_entries = []
    icons = {}
    for sp in server_processes:
        if sp.launcher_entry.enabled and sp.launcher_entry.icon_path:
            icons[sp.name] = sp.launcher_entry.icon_path

    nbapp.web_app.add_handlers('.*', [
        (ujoin(base_url, 'server-proxy/servers-info'), ServersInfoHandler, {'server_processes': server_processes}),
        (ujoin(base_url, 'server-proxy/icon/(.*)'), IconHandler, {'icons': icons})
    ]) 
开发者ID:jupyterhub,项目名称:jupyter-server-proxy,代码行数:25,代码来源:__init__.py

示例13: load_jupyter_server_extension

# 需要导入模块: from notebook import utils [as 别名]
# 或者: from notebook.utils import url_path_join [as 别名]
def load_jupyter_server_extension(nbapp):
    nbapp.log.info("geonotebook module enabled!")
    nbapp.web_app.settings['jinja2_env'].loader = \
        get_notebook_jinja2_loader(nbapp)

    webapp = nbapp.web_app
    conf = Config()

    conf.vis_server.initialize_webapp(conf, webapp)

    base_url = webapp.settings['base_url']

    for ep in pkg_resources.iter_entry_points(
            group='geonotebook.handlers.default'):
        webapp.add_handlers('.*$', [(url_path_join(base_url, ep.name),
                                     ep.load())]) 
开发者ID:OpenGeoscience,项目名称:geonotebook,代码行数:18,代码来源:__init__.py

示例14: load_jupyter_server_extension

# 需要导入模块: from notebook import utils [as 别名]
# 或者: from notebook.utils import url_path_join [as 别名]
def load_jupyter_server_extension(nb_server_app):
    """
    Called when the extension is loaded.

    Args:
        nb_server_app (NotebookWebApplication): handle to the Notebook webserver instance.
    """
    cluster_id_regex = r"(?P<cluster_id>\w+-\w+-\w+-\w+-\w+)"
    web_app = nb_server_app.web_app
    base_url = web_app.settings["base_url"]
    get_cluster_path = url_path_join(base_url, "dask/clusters/" + cluster_id_regex)
    list_clusters_path = url_path_join(base_url, "dask/clusters/" + "?")
    get_dashboard_path = url_path_join(
        base_url, f"dask/dashboard/{cluster_id_regex}(?P<proxied_path>.+)"
    )
    handlers = [
        (get_cluster_path, DaskClusterHandler),
        (list_clusters_path, DaskClusterHandler),
        (get_dashboard_path, DaskDashboardHandler),
    ]
    web_app.add_handlers(".*$", handlers) 
开发者ID:dask,项目名称:dask-labextension,代码行数:23,代码来源:__init__.py

示例15: load_jupyter_server_extension

# 需要导入模块: from notebook import utils [as 别名]
# 或者: from notebook.utils import url_path_join [as 别名]
def load_jupyter_server_extension(nb_server):
    from .handlers import QIIME2RedirectHandler, QIIME2ResultHandler
    from notebook.utils import url_path_join

    result_store = {}
    app = nb_server.web_app

    def route(path):
        return url_path_join(app.settings['base_url'], 'qiime2', path)

    app.add_handlers(r'.*', [
        (route(r'redirect'), QIIME2RedirectHandler,
         {'result_store': result_store}),
        (route(r'view/(.*)'), QIIME2ResultHandler,
         # This *is* odd, but it's because we are tricking StaticFileHandler
         {'path': result_store,
          'default_filename': 'index.html'})
    ]) 
开发者ID:qiime2,项目名称:qiime2,代码行数:20,代码来源:hooks.py


注:本文中的notebook.utils.url_path_join方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。