#14364: The jmol spkg contains testjava.sh
--------------------------------------+-------------------------
       Reporter:  Snark               |        Owner:  tbd
           Type:  enhancement         |       Status:  new
       Priority:  minor               |    Milestone:  sage-5.13
      Component:  packages: standard  |   Resolution:
       Keywords:                      |    Merged in:
        Authors:                      |    Reviewers:
Report Upstream:  N/A                 |  Work issues:
         Branch:                      |       Commit:
   Dependencies:                      |     Stopgaps:
--------------------------------------+-------------------------

Comment (by strogdon):

 Is there any interest in moving the functionality of `testjava.sh` into
 `jmoldata.py`? I'm not sure what is easiest to maintain, but I believe the
 following will work.

 {{{
 #!diff
 --- a/sage/interfaces/jmoldata.py
 +++ b/sage/interfaces/jmoldata.py
 @@ -86,13 +86,23 @@
              sage_makedirs(jmolscratch)
          scratchout = os.path.join(jmolscratch,"jmolout.txt")
          jout=open(scratchout,'w')
 -        testjavapath = os.path.join(SAGE_LOCAL, "share", "jmol",
 "testjava.sh")
 -        result = subprocess.call([testjavapath],stdout=jout)
 -        jout.close()
 -        if (result == 0):
 -            return (True)
 -        else:
 -            return (False)
 +        try:
 +            version = subprocess.check_output(['java', '-version'],
 stderr=subprocess.STDOUT)
 +            import re, types
 +            java_version = re.search("version.*[1]\.[567]", version)
 +            if type(java_version) is types.NoneType:
 +                jout.write('Your version of Java is either deprecated or
 not supported\nWe support versions 1.5 to 1.7\n')
 +                jout.close()
 +                result = bool(java_version)
 +            else:
 +                jout.write('You have a supported version of Java,
 Exiting\n')
 +                jout.close()
 +                result = bool(java_version)
 +        except (subprocess.CalledProcessError, OSError):
 +            jout.write('You do not have Java installed\nWe support
 versions 1.5 to 1.7\n')
 +            jout.close()
 +            result = False
 +        return result

      def export_image(self,
          targetfile,
 @@ -183,7 +193,7 @@
              if not os.path.exists(jmolscratch):
                  sage_makedirs(jmolscratch)
              scratchout = os.path.join(jmolscratch,"jmolout.txt")
 -            jout=open(scratchout,'w')
 +            jout=open(scratchout,'a')
              #now call the java application and write the file.
              result =
 
subprocess.call(["java","-Xmx512m","-Djava.awt.headless=true","-jar",jmolpath,"-iox","-g",sizeStr,"-J",launchscript,"-j",imagescript],stdout=jout)
              jout.close()

 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/14364#comment:8>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to