Beispiel #1
0
    def launch_jmol(self, output_jmol, plain_text):
        """
        Launch the stand-alone jmol viewer

        INPUT:

        - ``output_jmol`` --
          :class:`~sage.repl.rich_output.output_graphics3d.OutputSceneJmol`. The
          scene to launch Jmol with.

        - ``plain_text`` -- string. The plain text representation.

        OUTPUT:

        String. Human-readable message indicating that the viewer was launched.

        EXAMPLES::

            sage: from sage.repl.rich_output.backend_ipython import BackendIPythonCommandline
            sage: backend = BackendIPythonCommandline()
            sage: from sage.repl.rich_output.output_graphics3d import OutputSceneJmol
            sage: backend.launch_jmol(OutputSceneJmol.example(), 'Graphics3d object')
            'Launched jmol viewer for Graphics3d object'
        """
        from sage.doctest import DOCTEST_MODE
        from sage.interfaces.jmoldata import JmolData
        jdata = JmolData()
        if not jdata.is_jvm_available() and not DOCTEST_MODE:
            raise RuntimeError('jmol cannot run, no suitable java version found')
        launch_script = output_jmol.launch_script_filename()
        jmol_cmd = 'jmol'
        if not DOCTEST_MODE:
            os.system('{0} {1} 2>/dev/null 1>/dev/null &'
                      .format(jmol_cmd, launch_script))
        return 'Launched jmol viewer for {0}'.format(plain_text)
Beispiel #2
0
    def launch_jmol(self, output_jmol, plain_text):
        """
        Launch the stand-alone jmol viewer

        INPUT:

        - ``output_jmol`` --
          :class:`~sage.repl.rich_output.output_graphics3d.OutputSceneJmol`. The
          scene to launch Jmol with.

        - ``plain_text`` -- string. The plain text representation.

        OUTPUT:

        String. Human-readable message indicating that the viewer was launched.

        EXAMPLES::

            sage: from sage.repl.rich_output.backend_ipython import BackendIPythonCommandline
            sage: backend = BackendIPythonCommandline()
            sage: from sage.repl.rich_output.output_graphics3d import OutputSceneJmol
            sage: backend.launch_jmol(OutputSceneJmol.example(), 'Graphics3d object')
            'Launched jmol viewer for Graphics3d object'
        """
        from sage.doctest import DOCTEST_MODE
        from sage.interfaces.jmoldata import JmolData

        jdata = JmolData()
        if not jdata.is_jvm_available() and not DOCTEST_MODE:
            raise RuntimeError("jmol cannot run, no suitable java version found")
        launch_script = output_jmol.launch_script_filename()
        from sage.env import SAGE_LOCAL

        jmol_cmd = os.path.join(SAGE_LOCAL, "bin", "jmol")
        if not DOCTEST_MODE:
            os.system("{0} {1} 2>/dev/null 1>/dev/null &".format(jmol_cmd, launch_script))
        return "Launched jmol viewer for {0}".format(plain_text)