Beispiel #1
0
    def launch_viewer(self, image_file, plain_text):
        """
        Launch external viewer for the graphics file.

        INPUT:

        - ``image_file`` -- string. File name of the image file.

        - ``plain_text`` -- string. The plain text representation of
          the image file.

        OUTPUT:

        String. Human-readable message indicating whether the viewer
        was launched successfully.

        EXAMPLES::

            sage: from sage.repl.rich_output.backend_ipython import BackendIPythonCommandline
            sage: backend = BackendIPythonCommandline()
            sage: backend.launch_viewer('/path/to/foo.bar', 'Graphics object')
            'Launched bar viewer for Graphics object'
        """
        base, dot_ext = os.path.splitext(image_file)
        ext = dot_ext.lstrip(os.path.extsep)
        from sage.misc.viewer import viewer
        command = viewer(ext)
        if not command:
            command = viewer.browser()
        from sage.doctest import DOCTEST_MODE
        if not DOCTEST_MODE:
            os.system('{0} {1} 2>/dev/null 1>/dev/null &'.format(
                command, image_file))
        return 'Launched {0} viewer for {1}'.format(ext, plain_text)
Beispiel #2
0
    def launch_viewer(self):
        """
        Launch external viewer for the graphics file.

        .. note::

            Does not actually launch a new process when doctesting.

        EXAMPLES::

            sage: from sage.structure.graphics_file import GraphicsFile
            sage: g = GraphicsFile('/tmp/test.png', 'image/png')
            sage: g.launch_viewer()
        """
        if sage.doctest.DOCTEST_MODE:
            return
        from sage.plot.plot import EMBEDDED_MODE
        if EMBEDDED_MODE:
            raise RuntimeError('should never launch viewer in embedded mode')
        if self.mime() == Mime.JMOL:
            return self._launch_jmol()
        from sage.misc.viewer import viewer
        command = viewer(preferred_filename_ext[self.mime()])
        os.system('{0} {1} 2>/dev/null 1>/dev/null &'.format(
            command, self.filename()))
    def launch_viewer(self, image_file, plain_text):
        """
        Launch external viewer for the graphics file.

        INPUT:

        - ``image_file`` -- string. File name of the image file.

        - ``plain_text`` -- string. The plain text representation of
          the image file.

        OUTPUT:

        String. Human-readable message indicating whether the viewer
        was launched successfully.

        EXAMPLES::

            sage: from sage.repl.rich_output.backend_ipython import BackendIPythonCommandline
            sage: backend = BackendIPythonCommandline()
            sage: backend.launch_viewer('/path/to/foo.bar', 'Graphics object')
            'Launched bar viewer for Graphics object'
        """
        base, dot_ext = os.path.splitext(image_file)
        ext = dot_ext.lstrip(os.path.extsep)
        from sage.misc.viewer import viewer
        command = viewer(ext)
        if not command:
            command = viewer.browser()
        from sage.doctest import DOCTEST_MODE
        if not DOCTEST_MODE:
            os.system('{0} {1} 2>/dev/null 1>/dev/null &'
                      .format(command, image_file))
        return 'Launched {0} viewer for {1}'.format(ext, plain_text)
Beispiel #4
0
    def launch_viewer(self):
        """
        Launch external viewer for the graphics file.

        .. note::

            Does not actually launch a new process when doctesting.

        EXAMPLES::

            sage: from sage.structure.graphics_file import GraphicsFile
            sage: g = GraphicsFile('/tmp/test.png', 'image/png')
            sage: g.launch_viewer()
        """
        if sage.doctest.DOCTEST_MODE:
            return
        from sage.plot.plot import EMBEDDED_MODE
        if EMBEDDED_MODE:
            raise RuntimeError('should never launch viewer in embedded mode')
        if self.mime() == Mime.JMOL:
            return self._launch_jmol()
        from sage.misc.viewer import viewer
        command = viewer(preferred_filename_ext[self.mime()])
        os.system('{0} {1} 2>/dev/null 1>/dev/null &'
                  .format(command, self.filename()))