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