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


Python kernelspec.KernelSpecManager方法代码示例

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


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

示例1: run

# 需要导入模块: from jupyter_client import kernelspec [as 别名]
# 或者: from jupyter_client.kernelspec import KernelSpecManager [as 别名]
def run(self):
        # Regular install
        install.run(self)

        # Post install
        print('Installing Ansible Kernel kernelspec')
        from jupyter_client.kernelspec import KernelSpecManager
        from IPython.utils.tempdir import TemporaryDirectory
        kernel_json = {
            "argv": ["python", "-m", "ansible_kernel", "-f", "{connection_file}"],
            "codemirror_mode": "yaml",
            "display_name": "Ansible",
            "language": "ansible"
        }
        with TemporaryDirectory() as td:
            os.chmod(td, 0o755)
            with open(os.path.join(td, 'kernel.json'), 'w') as f:
                json.dump(kernel_json, f, sort_keys=True)
            ksm = KernelSpecManager()
            ksm.install_kernel_spec(td, 'ansible', user=self.user, replace=True, prefix=self.prefix) 
开发者ID:ansible,项目名称:ansible-jupyter-kernel,代码行数:22,代码来源:setup.py

示例2: run

# 需要导入模块: from jupyter_client import kernelspec [as 别名]
# 或者: from jupyter_client.kernelspec import KernelSpecManager [as 别名]
def run(self):
        # Regular installation
        install.run(self)

        # Now write the kernelspec
        from jupyter_client.kernelspec import KernelSpecManager
        from tempfile import TemporaryDirectory
        kernel_spec = KernelSpecManager()
        with TemporaryDirectory() as td:
            os.chmod(td, 0o755)  # Starts off as 700, not user readable
            with open(os.path.join(td, 'kernel.json'), 'w') as f:
                json.dump(kernel_json, f, sort_keys=True)
            # TODO: Copy resources once they're specified

            kernel_spec.install_kernel_spec(td, 'postgres', user=self.user) 
开发者ID:bgschiller,项目名称:postgres_kernel,代码行数:17,代码来源:setup.py

示例3: install_sos_kernel_spec

# 需要导入模块: from jupyter_client import kernelspec [as 别名]
# 或者: from jupyter_client.kernelspec import KernelSpecManager [as 别名]
def install_sos_kernel_spec(args):
    user = False
    prefix = None
    if args.sys_prefix:
        prefix = sys.prefix
    elif args.prefix:
        prefix = args.prefix
    elif args.user or not _is_root():
        user = True

    with TemporaryDirectory() as td:
        os.chmod(td, 0o755)  # Starts off as 700, not user readable
        with open(os.path.join(td, 'kernel.json'), 'w') as f:
            json.dump(kernel_json, f, sort_keys=True)
        # Copy resources once they're specified
        shutil.copy(
            os.path.join(os.path.split(__file__)[0], 'kernel.js'),
            os.path.join(td, 'kernel.js'))
        shutil.copy(
            os.path.join(os.path.split(__file__)[0], 'logo-64x64.png'),
            os.path.join(td, 'logo-64x64.png'))

        KS = KernelSpecManager()
        KS.log.setLevel(logging.ERROR)
        KS.install_kernel_spec(td, 'sos', user=user, prefix=prefix)
        print('sos jupyter kernel spec is installed') 
开发者ID:vatlab,项目名称:sos-notebook,代码行数:28,代码来源:install.py

示例4: _get_default_kernel_name

# 需要导入模块: from jupyter_client import kernelspec [as 别名]
# 或者: from jupyter_client.kernelspec import KernelSpecManager [as 别名]
def _get_default_kernel_name():
    return next(iter(KernelSpecManager().find_kernel_specs().keys())) 
开发者ID:awslabs,项目名称:aws-iot-analytics-notebook-containers,代码行数:4,代码来源:iota_run_nb.py

示例5: install_kernel

# 需要导入模块: from jupyter_client import kernelspec [as 别名]
# 或者: from jupyter_client.kernelspec import KernelSpecManager [as 别名]
def install_kernel(cmd):
    # Install the kernel spec when we install the package
    from ipykernel import kernelspec
    from jupyter_client.kernelspec import KernelSpecManager

    kernel_name = 'geonotebook%i' % sys.version_info[0]

    path = os.path.join(tempfile.mkdtemp(suffix='_kernels'), kernel_name)
    try:
        os.makedirs(path)
    except OSError:
        pass

    kernel_dict = {
        'argv': kernelspec.make_ipkernel_cmd(mod='geonotebook'),
        'display_name': 'Geonotebook (Python %i)' % sys.version_info[0],
        'language': 'python',
    }

    with open(os.path.join(path, 'kernel.json'), 'w') as fh:
        json.dump(kernel_dict, fh, indent=1)

    ksm = KernelSpecManager()
    ksm.install_kernel_spec(
        path, kernel_name=kernel_name, user=False, prefix=sys.prefix)

    shutil.rmtree(path)


# shamelessly taken from ipyleaflet: https://github.com/ellisonbg/ipyleaflet
# Copyright (c) 2014 Brian E. Granger 
开发者ID:OpenGeoscience,项目名称:geonotebook,代码行数:33,代码来源:setup.py

示例6: get_kernelspec

# 需要导入模块: from jupyter_client import kernelspec [as 别名]
# 或者: from jupyter_client.kernelspec import KernelSpecManager [as 别名]
def get_kernelspec(self, name):
        """Get a kernel specification dictionary given a kernel name
        """
        ksm = KernelSpecManager()
        kernelspec = ksm.get_kernel_spec(name).to_dict()
        kernelspec['name'] = name
        kernelspec.pop('argv')
        return kernelspec 
开发者ID:elehcimd,项目名称:pynb,代码行数:10,代码来源:notebook.py


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