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


Python ConfigManager.update方法代码示例

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


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

示例1: install_server_extension

# 需要导入模块: from notebook.services.config import ConfigManager [as 别名]
# 或者: from notebook.services.config.ConfigManager import update [as 别名]
def install_server_extension(enable=True):
    """Register ipyparallel clusters tab as a notebook server extension
    
    Toggle with enable=True/False.
    """
    # server-side
    server = BaseJSONConfigManager(config_dir=jupyter_config_dir())
    server_cfg = server.get('jupyter_notebook_config')
    app_cfg = server_cfg.get('NotebookApp', {})
    server_extensions = app_cfg.get('server_extensions', [])
    server_ext = 'ipyparallel.nbextension'
    server_changed = False
    if enable and server_ext not in server_extensions:
        server_extensions.append(server_ext)
        server_changed = True
    elif (not enable) and server_ext in server_extensions:
        server_extensions.remove(server_ext)
        server_changed = True
    if server_changed:
        server.update('jupyter_notebook_config', {
            'NotebookApp': {
                'server_extensions': server_extensions,
            }
        })
    
    # frontend config (*way* easier because it's a dict)
    frontend = FrontendConfigManager()
    frontend.update('tree', {
        'load_extensions': {
            'ipyparallel/main': enable or None,
        }
    })
开发者ID:AminJamalzadeh,项目名称:ipyparallel,代码行数:34,代码来源:install.py

示例2: _install_extension_nb41

# 需要导入模块: from notebook.services.config import ConfigManager [as 别名]
# 或者: from notebook.services.config.ConfigManager import update [as 别名]
def _install_extension_nb41(enable=True):
    """deprecated, pre-4.2 implementation of installing notebook extension"""
    # server-side
    server = BaseJSONConfigManager(config_dir=jupyter_config_dir())
    server_cfg = server.get('jupyter_notebook_config')
    app_cfg = server_cfg.get('NotebookApp', {})
    server_extensions = app_cfg.get('server_extensions', [])
    server_ext = 'ipyparallel.nbextension'
    server_changed = False
    if enable and server_ext not in server_extensions:
        server_extensions.append(server_ext)
        server_changed = True
    elif (not enable) and server_ext in server_extensions:
        server_extensions.remove(server_ext)
        server_changed = True
    if server_changed:
        server.update('jupyter_notebook_config', {
            'NotebookApp': {
                'server_extensions': server_extensions,
            }
        })
    
    # frontend config (*way* easier because it's a dict)
    frontend = FrontendConfigManager()
    frontend.update('tree', {
        'load_extensions': {
            'ipyparallel/main': enable or None,
        }
    })
开发者ID:Ruk0610,项目名称:ipyparallel,代码行数:31,代码来源:install.py

示例3: install

# 需要导入模块: from notebook.services.config import ConfigManager [as 别名]
# 或者: from notebook.services.config.ConfigManager import update [as 别名]
def install(user=False, symlink=False, overwrite=False, enable=False,
            **kwargs):
    """Install the nbpresent nbextension.

    Parameters
    ----------
    user: bool
        Install for current user instead of system-wide.
    symlink: bool
        Symlink instead of copy (for development).
    overwrite: bool
        Overwrite previously-installed files for this extension
    enable: bool
        Enable the extension on every notebook launch
    **kwargs: keyword arguments
        Other keyword arguments passed to the install_nbextension command
    """
    print("Installing nbpresent nbextension...")
    directory = join(dirname(abspath(__file__)), 'static', 'nbpresent')
    install_nbextension(directory, destination='nbpresent',
                        symlink=symlink, user=user, overwrite=overwrite,
                        **kwargs)

    if enable:
        print("Enabling nbpresent at every notebook launch...")
        cm = ConfigManager()
        cm.update('notebook',
                  {"load_extensions": {"nbpresent/nbpresent.min": True}})
开发者ID:fiolbs,项目名称:nbpresent,代码行数:30,代码来源:install.py

示例4: install

# 需要导入模块: from notebook.services.config import ConfigManager [as 别名]
# 或者: from notebook.services.config.ConfigManager import update [as 别名]
def install(user=False, symlink=False, quiet=False, enable=False):
    """Install the widget nbextension and optionally enable it.
    
    Parameters
    ----------
    user: bool
        Install for current user instead of system-wide.
    symlink: bool
        Symlink instead of copy (for development).
    enable: bool
        Enable the extension after installing it.
    quiet: bool
        Suppress print statements about progress.
    """
    if not quiet:
        print("Installing nbextension ...")
    staticdir = pjoin(dirname(abspath(__file__)), "static")
    install_nbextension(staticdir, destination="widgets", user=user, symlink=symlink)

    if enable:
        if not quiet:
            print("Enabling the extension ...")
        cm = ConfigManager()
        cm.update("notebook", {"load_extensions": {"widgets/extension": True}})
    if not quiet:
        print("Done.")
开发者ID:parente,项目名称:ipywidgets,代码行数:28,代码来源:install.py

示例5: start

# 需要导入模块: from notebook.services.config import ConfigManager [as 别名]
# 或者: from notebook.services.config.ConfigManager import update [as 别名]
 def start(self):
     self.log.info("Activating jupyter_dashboards_bundlers JS notebook extensions")
     cm = ConfigManager(parent=self, config=self.config)
     cm.update('notebook', { 
         'jupyter_cms_bundlers': {
             'dashboards_local_deploy': {
                 'label': 'Local Dashboard',
                 'module_name': 'dashboards_bundlers.local_deploy',
                 'group': 'deploy'
             },
             'dashboards_php_download': {
                 'label': 'PHP Dashboard bundle (.zip)',
                 'module_name': 'dashboards_bundlers.php_download',
                 'group': 'download'
             },
             'dashboards_server_upload': {
                 'label': 'Dashboard on Jupyter Dashboards Server',
                 'module_name': 'dashboards_bundlers.server_upload',
                 'group': 'deploy'
             },
             'dashboards_server_download': {
                 'label': 'Jupyter Dashboards Server bundle (.zip)',
                 'module_name': 'dashboards_bundlers.server_download',
                 'group': 'download'
             }
         }
     })
     self.log.info("Done.")
开发者ID:ScottJWalter,项目名称:dashboards_bundlers,代码行数:30,代码来源:extensionapp.py

示例6: install

# 需要导入模块: from notebook.services.config import ConfigManager [as 别名]
# 或者: from notebook.services.config.ConfigManager import update [as 别名]
def install(config_dir, use_symlink=False, enable=True):
    # Install the livereveal code.
    install_nbextension(livereveal_dir, symlink=use_symlink,
                        overwrite=use_symlink, user=True)

    if enable:
        cm = ConfigManager(config_dir=config_dir)
        cm.update('notebook', {"load_extensions": {"livereveal/main": True}})
开发者ID:bwilk7,项目名称:RISE,代码行数:10,代码来源:setup.py

示例7: disable_nbextension

# 需要导入模块: from notebook.services.config import ConfigManager [as 别名]
# 或者: from notebook.services.config.ConfigManager import update [as 别名]
 def disable_nbextension(self, name):
     # Local import to avoid circular import issue on Py 2
     from notebook.services.config import ConfigManager
     cm = ConfigManager(parent=self, config=self.config)
     if name not in cm.get(self.section).get('load_extensions', {}):
         sys.exit('{} is not enabled in section {}'.format(name, self.section))
     # We're using a dict as a set - updating with None removes the key
     cm.update(self.section, {"load_extensions": {name: None}})
开发者ID:nwhitehead,项目名称:notebook,代码行数:10,代码来源:nbextensions.py

示例8: disable_bundler

# 需要导入模块: from notebook.services.config import ConfigManager [as 别名]
# 或者: from notebook.services.config.ConfigManager import update [as 别名]
 def disable_bundler(self):
     '''Disables the notebook bundler extension.'''
     cm = ConfigManager(parent=self, config=self.config)
     cm.update('notebook', { 
         'jupyter_cms_bundlers': {
             'notebook_associations_download': None
         }
     })
开发者ID:jupyter-incubator,项目名称:contentmanagement,代码行数:10,代码来源:extensionapp.py

示例9: install

# 需要导入模块: from notebook.services.config import ConfigManager [as 别名]
# 或者: from notebook.services.config.ConfigManager import update [as 别名]
def install(enable=False, **kwargs):
    """Install the nbpresent nbextension assets and optionally enables the
       nbextension and server extension for every run.

    Parameters
    ----------
    enable: bool
        Enable the extension on every notebook launch
    **kwargs: keyword arguments
        Other keyword arguments passed to the install_nbextension command
    """
    from notebook.nbextensions import install_nbextension
    from notebook.services.config import ConfigManager

    directory = join(dirname(abspath(__file__)), "static", "nbpresent")

    kwargs = {k: v for k, v in kwargs.items() if not (v is None)}

    kwargs["destination"] = "nbpresent"
    install_nbextension(directory, **kwargs)

    if enable:
        path = jupyter_config_dir()
        if "prefix" in kwargs:
            path = join(kwargs["prefix"], "etc", "jupyter")
            if not exists(path):
                print("Making directory", path)
                os.makedirs(path)

        cm = ConfigManager(config_dir=path)
        print("Enabling nbpresent server component in", cm.config_dir)
        cfg = cm.get("jupyter_notebook_config")
        print("Existing config...")
        pprint(cfg)
        server_extensions = cfg.setdefault("NotebookApp", {}).setdefault("server_extensions", [])
        if "nbpresent" not in server_extensions:
            cfg["NotebookApp"]["server_extensions"] += ["nbpresent"]

        cm.update("jupyter_notebook_config", cfg)
        print("New config...")
        pprint(cm.get("jupyter_notebook_config"))

        _jupyter_config_dir = jupyter_config_dir()
        # try:
        #     subprocess.call(["conda", "info", "--root"])
        #     print("conda detected")
        #     _jupyter_config_dir = ENV_CONFIG_PATH[0]
        # except OSError:
        #     print("conda not detected")

        cm = ConfigManager(config_dir=join(_jupyter_config_dir, "nbconfig"))
        print("Enabling nbpresent nbextension at notebook launch in", cm.config_dir)

        if not exists(cm.config_dir):
            print("Making directory", cm.config_dir)
            os.makedirs(cm.config_dir)

        cm.update("notebook", {"load_extensions": {"nbpresent/nbpresent.min": True}})
开发者ID:bollwyvl,项目名称:nbpresent,代码行数:60,代码来源:install.py

示例10: start

# 需要导入模块: from notebook.services.config import ConfigManager [as 别名]
# 或者: from notebook.services.config.ConfigManager import update [as 别名]
 def start(self):
     self.log.info("Deactivating jupyter_kernel_gateway_bundlers notebook extension")
     cm = ConfigManager(parent=self, config=self.config)
     cm.update('notebook', {
         'jupyter_cms_bundlers': {
             'microservice_dockerfile_download' : None
         }
     })
     self.log.info("Done.")
开发者ID:jupyter-incubator,项目名称:kernel_gateway_bundlers,代码行数:11,代码来源:extensionapp.py

示例11: config_configManager

# 需要导入模块: from notebook.services.config import ConfigManager [as 别名]
# 或者: from notebook.services.config.ConfigManager import update [as 别名]
def config_configManager():
    print("Update ConfigManager")
    from notebook.services.config import ConfigManager
    cm = ConfigManager()
    cm.update('livereveal', {
              'theme': 'serif',
              'start_slideshow_at': 'selected',
              'width': 1680,
              'height': 768,
    })
开发者ID:r0k3,项目名称:thalesians,代码行数:12,代码来源:config.py

示例12: install

# 需要导入模块: from notebook.services.config import ConfigManager [as 别名]
# 或者: from notebook.services.config.ConfigManager import update [as 别名]
def install(enable=False, disable=False, prefix=None):
    """Install the nb_config_manager config piece.

    Parameters
    ----------
    enable: bool
        Enable the nb_config_manager on every notebook launch
    disable: bool
        Disable nb_config_manager on every notebook launch
    """
    from notebook.services.config import ConfigManager

    if enable:
        if prefix is not None:
            path = join(prefix, "etc", "jupyter")
            if not exists(path):
                print("Making directory", path)
                os.makedirs(path)
        else:
            path = jupyter_config_dir()

        cm = ConfigManager(config_dir=path)
        print("Enabling nb_config_manager in", cm.config_dir)
        cfg = cm.get("jupyter_notebook_config")
        print("Existing config...")
        pprint(cfg)

        notebook_app = cfg.setdefault("NotebookApp", {})
        if "config_manager_class" not in notebook_app:
            cfg["NotebookApp"]["config_manager_class"] = "nb_config_manager.EnvironmentConfigManager"

        cm.update("jupyter_notebook_config", cfg)
        print("New config...")
        pprint(cm.get("jupyter_notebook_config"))

    if disable:
        if prefix is not None:
            path = join(prefix, "etc", "jupyter")
        else:
            path = jupyter_config_dir()

        cm = ConfigManager(config_dir=path)
        print("Disabling nb_config_manager in", cm.config_dir)
        cfg = cm.get("jupyter_notebook_config")
        print("Existing config...")
        pprint(cfg)

        config_manager = cfg["NotebookApp"]["config_manager_class"]

        if "nb_config_manager.EnvironmentConfigManager" == config_manager:
            cfg["NotebookApp"].pop("config_manager_class")

        cm.set("jupyter_notebook_config", cfg)
        print("New config...")
        pprint(cm.get("jupyter_notebook_config"))
开发者ID:fdeheeger,项目名称:nb_config_manager,代码行数:57,代码来源:install.py

示例13: run

# 需要导入模块: from notebook.services.config import ConfigManager [as 别名]
# 或者: from notebook.services.config.ConfigManager import update [as 别名]
 def run(self):
     _develop.run(self)
     install_nbextension(
         extension_dir,
         symlink=True,
         overwrite=True,
         user=False,
         sys_prefix=True,  # to install it inside virtualenv
         destination="robomission")
     cm = ConfigManager()
     cm.update('notebook', {"load_extensions": {"robomission/index": True } })
开发者ID:adaptive-learning,项目名称:robomission,代码行数:13,代码来源:setup.py

示例14: start

# 需要导入模块: from notebook.services.config import ConfigManager [as 别名]
# 或者: from notebook.services.config.ConfigManager import update [as 别名]
 def start(self):
     self.log.info("Deactivating jupyter_dashboards_bundlers JS notebook extensions")
     cm = ConfigManager(parent=self, config=self.config)
     cm.update('notebook', { 
         'jupyter_cms_bundlers': {
             'dashboards_local_deploy' : None,
             'dashboards_php_download' : None,
             'dashboards_server_upload' : None
         }
     })
     self.log.info("Done.")
开发者ID:deedubbu,项目名称:dashboards_bundlers,代码行数:13,代码来源:extensionapp.py

示例15: run_nbextension_install

# 需要导入模块: from notebook.services.config import ConfigManager [as 别名]
# 或者: from notebook.services.config.ConfigManager import update [as 别名]
 def run_nbextension_install(develop):
     import sys
     sysprefix = hasattr(sys, 'real_prefix')
     if sysprefix:
         install_nbextension(extension_dir, symlink=develop, sys_prefix=sysprefix)
     else:
         install_nbextension(extension_dir, symlink=develop, user=user)
     if enable is not None:
         print("Enabling the extension ...")
         cm = ConfigManager()
         cm.update('notebook', {"load_extensions": {enable: True}})
开发者ID:exe0cdc,项目名称:jupyter-pip,代码行数:13,代码来源:__init__.py


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