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)
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)