I'm attaching a referee patch which removes the code duplication referred to above.
Karl-Dieter: the program "sage-open", as defined in sage/misc/viewer.py, should be used to open the output file. Before the patch here, it was called with output_file set to "sage.dvi" or something like that. After the patch, it is called with output_file set to "sage.pdf". So any difference in what program is being used is because this is producing a pdf file, not a dvi file.
I'd like to change this from "needs info" to "positive review". Is that okay?