|
683 | 683 | #*****************************************************************************
|
684 | 684 |
|
685 | 685 | import os
|
| 686 | +import re |
686 | 687 |
|
687 | 688 | from sage.cpython.string import bytes_to_str
|
688 | 689 | from sage.misc.pager import pager
|
689 | 690 | from sage.misc.superseded import deprecation
|
690 | 691 | from sage.misc.temporary_file import tmp_filename
|
691 | 692 | from sage.structure.sage_object import SageObject
|
| 693 | +from sage.misc.cachefunc import cached_method |
692 | 694 |
|
693 | 695 |
|
694 | 696 | class TachyonRT(SageObject):
|
@@ -799,6 +801,11 @@ def __call__(self, model, outfile='sage.png', verbose=1, extra_opts=''):
|
799 | 801 | Parser failed due to an input file syntax error.
|
800 | 802 | Aborting render.
|
801 | 803 | """
|
| 804 | + if self.version() >= '0.99.2': |
| 805 | + # this keyword was changed in 0.99.2 |
| 806 | + model = model.replace( |
| 807 | + " focallength ", |
| 808 | + " focaldist ") |
802 | 809 | modelfile = tmp_filename(ext='.dat')
|
803 | 810 | with open(modelfile, 'w') as file:
|
804 | 811 | file.write(model)
|
@@ -851,6 +858,25 @@ def usage(self, use_pager=True):
|
851 | 858 | else:
|
852 | 859 | print(r)
|
853 | 860 |
|
| 861 | + @cached_method |
| 862 | + def version(self): |
| 863 | + """ |
| 864 | + Returns the version of the Tachyon raytracer being used. |
| 865 | +
|
| 866 | + TESTS:: |
| 867 | +
|
| 868 | + sage: tachyon_rt.version() # random |
| 869 | + 0.98.9 |
| 870 | + sage: tachyon_rt.version() >= '0.98.9' |
| 871 | + True |
| 872 | + """ |
| 873 | + with os.popen('tachyon') as f: |
| 874 | + r = f.readline() |
| 875 | + res = re.search(r"Version ([\d.]*)", r) |
| 876 | + # debian patches tachyon so it won't report the version |
| 877 | + # we hardcode '0.99' since that's indeed the version they ship |
| 878 | + return res[1] if res else '0.99' |
| 879 | + |
854 | 880 | def help(self, use_pager=True):
|
855 | 881 | """
|
856 | 882 | Deprecated: type 'sage.interfaces.tachyon?' for help
|
|
0 commit comments