Adam R. B. Jack wrote:

And finally, a nit: I see useful information like the name of the java
command ("java") and the Operating System ("posix"), but I don't see the
values of System.getProperties which contains values such as:

       java.vm.version=1.4.2_04-b05
       java.vm.vendor=Sun Microsystems Inc.
       os.arch=i386
       os.name=Linux

Hmm. No, not directly. If a project repeatedly fails Gump automatically turns on ant verbose and/or debug, and maybe this show those values. Is there a way to list these things (above) without writing some Java?

What's wrong with writing some Java? ;-)


import commands, os, re

TMP_DIR = '/home/rubys/tmp'
JAVA_SOURCE = TMP_DIR + '/sysprop.java'

properties = [
  'java.vendor',
  'java.version',
  'os.name',
  'os.arch',
  'os.version'
]

source=open(JAVA_SOURCE,'w')
source.write("""
  public class sysprop {
    public static void main(String [] args) {
      for (int i=0; i<args.length; i++) {
        System.out.print(args[i]);
        System.out.print(": ");
        System.out.println(System.getProperty(args[i]));
      }
    }
  }
""")
source.close()

os.system('javac ' + JAVA_SOURCE)
os.unlink(JAVA_SOURCE)

cmd='java -cp ' + TMP_DIR + ' sysprop ' + ' '.join(properties)
properties = dict(re.findall('(.*?): (.*)', commands.getoutput(cmd)))
os.unlink(JAVA_SOURCE.replace('.java','.class'))

for (key,value) in properties.items():
  print key, "=>", value

- Sam Ruby

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to