本文整理汇总了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,
}
})
示例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,
}
})
示例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}})
示例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.")
示例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.")
示例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}})
示例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}})
示例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
}
})
示例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}})
示例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.")
示例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,
})
示例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"))
示例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 } })
示例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.")
示例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}})