當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。