Esempio n. 1
0
    def _install_spec(self):
        """
        Install the Sage IPython kernel
        
        It is safe to call this method multiple times, only one Sage
        kernel spec is ever installed for any given Sage
        version. However, it resets the IPython kernel spec directory
        so additional resources symlinked there are lost. See
        :meth:`symlink_resources`.

        EXAMPLES::

            sage: from sage.repl.ipython_kernel.install import SageKernelSpec
            sage: spec = SageKernelSpec()
            sage: spec._install_spec()    # not tested
        """
        import json

        temp = tmp_dir()
        kernel_spec = os.path.join(temp, "kernel.json")
        with open(kernel_spec, "w") as f:
            json.dump(self.kernel_spec(), f)
        identifier = self.identifier()
        install_kernel_spec(temp, identifier, user=True, replace=True)
        self._spec = get_kernel_spec(identifier)
Esempio n. 2
0
def install_my_kernel_spec(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)

        print('Installing IPython kernel spec')
        install_kernel_spec(td, 'stata', user=user, replace=True)
Esempio n. 3
0
def install_my_kernel_spec(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)

        print('Installing IPython kernel spec')
        install_kernel_spec(td, 'stata', user=user, replace=True)
Esempio n. 4
0
def install_my_kernel_spec(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)
        # TODO: Copy resources once they're specified

        print('Installing IPython kernel spec')
        install_kernel_spec(td, 'calysto_lc3', user=user, replace=True)
Esempio n. 5
0
    def run(self):
        install.run(self)
        from IPython.kernel.kernelspec import install_kernel_spec
        from IPython.utils.tempdir import TemporaryDirectory

        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)
            log.info("Installing kernel spec")
            try:
                install_kernel_spec(td, "metakernel_bash", user=self.user, replace=True)
            except:
                install_kernel_spec(td, "metakernel_bash", user=not self.user, replace=True)
Esempio n. 6
0
    def run(self):
        # Regular installation
        install.run(self)

        # Now write the kernelspec
        from IPython.kernel.kernelspec import install_kernel_spec
        from IPython.utils.tempdir import TemporaryDirectory
        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

            log.info('Installing IPython kernel spec')
            install_kernel_spec(td, 'bash', user=self.user, replace=True)
Esempio n. 7
0
 def run(self):
     install.run(self)
     from IPython.kernel.kernelspec import install_kernel_spec
     from IPython.utils.tempdir import TemporaryDirectory
     from metakernel.utils.kernel import install_kernel_resources
     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)
         install_kernel_resources(td, resource="calysto_scheme")
         log.info('Installing kernel spec')
         try:
             install_kernel_spec(td, 'calysto_scheme', replace=True)
         except:
             install_kernel_spec(td, 'calysto_scheme', user=self.user, replace=True)
Esempio n. 8
0
    def run(self):
        # Regular installation
        install.run(self)

        # Now write the kernelspec
        from IPython.kernel.kernelspec import install_kernel_spec
        from IPython.utils.tempdir import TemporaryDirectory
        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

            log.info('Installing IPython kernel spec')
            install_kernel_spec(td, 'postgres', user=self.user, replace=True)
Esempio n. 9
0
def install_spec():
    user = '******' in sys.argv
    from IPython.kernel.kernelspec import install_kernel_spec
    from IPython.utils.tempdir import TemporaryDirectory
    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)
        log.info('Installing kernel spec')
        try:
            install_kernel_spec(td, "matlab_kernel", user=user,
                                replace=True)
        except:
            install_kernel_spec(td, "matlab_kernel", user=not user,
                                replace=True)
Esempio n. 10
0
def install_spec():
    user = '******' in sys.argv
    from IPython.kernel.kernelspec import install_kernel_spec
    from IPython.utils.tempdir import TemporaryDirectory
    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)
        log.info('Installing kernel spec')
        try:
            install_kernel_spec(td, "matlab_kernel", user=user, replace=True)
        except:
            install_kernel_spec(td,
                                "matlab_kernel",
                                user=not user,
                                replace=True)
Esempio n. 11
0
 def run(self):
     install.run(self)
     from IPython.kernel.kernelspec import install_kernel_spec
     from IPython.utils.tempdir import TemporaryDirectory
     from metakernel.utils.kernel import install_kernel_resources
     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)
         install_kernel_resources(td, resource="calysto_scheme")
         log.info('Installing kernel spec')
         try:
             install_kernel_spec(td, 'calysto_scheme', replace=True)
         except:
             install_kernel_spec(td,
                                 'calysto_scheme',
                                 user=self.user,
                                 replace=True)
Esempio n. 12
0
    def _install_spec(self):
        """
        Install the Sage IPython kernel
        
        It is safe to call this method multiple times, only one Sage
        kernel spec is ever installed for any given Sage
        version. However, it resets the IPython kernel spec directory
        so additional resources symlinked there are lost. See
        :meth:`symlink_resources`.

        EXAMPLES::

            sage: from sage.repl.ipython_kernel.install import SageKernelSpec
            sage: spec = SageKernelSpec()
            sage: spec._install_spec()    # not tested
        """
        import json
        temp = tmp_dir()
        kernel_spec = os.path.join(temp, 'kernel.json')
        with open(kernel_spec, 'w') as f:
            json.dump(self.kernel_spec(), f)
        identifier = self.identifier()
        install_kernel_spec(temp, identifier, user=True, replace=True)
        self._spec = get_kernel_spec(identifier)
Esempio n. 13
0
def install(user=True):
    """ Install IPython kernel specification """
    folder = os.path.join(os.path.dirname(__file__), 'kernels', 'splash')
    install_kernel_spec(folder, kernel_name="splash", user=user, replace=True)
Esempio n. 14
0
 def run(self):
     install.run(self)
     from IPython.kernel.kernelspec import install_kernel_spec
     install_kernel_spec('kernelspec', 'forth', replace=True)
Esempio n. 15
0
 def run(self):
     install.run(self)
     from IPython.kernel.kernelspec import install_kernel_spec
     install_kernel_spec('kernelspec', 'forth', replace=True)
Esempio n. 16
0
def install(user=True):
    """ Install IPython kernel specification """
    folder = os.path.join(os.path.dirname(__file__), 'kernels', 'splash')
    install_kernel_spec(folder, kernel_name="splash", user=user, replace=True)