My problem is one like a simulated problem from http://my.safaribooksonline.com/0596007973/pythoncook2-CHP-10-SECT-17 which eventually made its way into Python Cookbook, 2nd Edition using an outdated xpath method from 2005 that I haven't been able to get to work with 10.6's build-in python(nor installing older packages)
I want to ... "retrieve detailed information about a Mac OS X system" using system_profiler to summarize it in a script each time a computer starts up(The script will launch on login).
The information I'm gathering varies from SW versions to HW config.
An example line is, system_profiler SPSoftwareDataType | grep 'Boot Volume' which returns the startup volume name. I make 15 to 20 other calls for information.
I've tried to output the full 'system_profiler > data' and parse that using cat data | grep, but that's obviously inefficient to the point where it's been faster if I just run each line like my example above.
18 seconds if ouputting to a file and cat | grep.
13 seconds if making individual calls
*I'm trying to make it as fast as possible.
I deduce that I probably need to create a dictionary and use keys to reference out the data but I'm wondering what's the most efficient way for me to parse and retrieve the data? I've seen a suggestion elsewhere to use system_profiler to output to XML and use a XML parser but I think there's probably some cache and parse method that does it more efficiently than outputting to a file first.