saltstack/salt — pull request #2177 by thekuffs (2012-10-05 20:53:28+00:00)
Title: Rework some Windows grains to use WMI

This pull request comes about as a part of some discussion in #2123. This reworks some Windows grains to use WMI instead of ```cmd.exe``` to call ```systeminfo```. Calls to ```systeminfo``` on my test VM take at least 1.5s.

Here's some output from my testing.
```
running old windows platform data
2012-10-05 13:22:17.390000
2012-10-05 13:22:19.250000
done running old windows platform data
===== 0:00:01.860000 ====
running new windows platform data
2012-10-05 13:22:19.250000
2012-10-05 13:22:19.515000
done running new windows platform data
===== 0:00:00.265000 ====
---------------------------
total savings: 0:00:01.595000
```

It also replaces the ```'inputlocale'``` grain with two more grains that come from the Python standard library: ```'defaultencoding'``` and ```'defaultlanguage'```.

This is what it returns now for my Windows test minion:
```yaml
timezone: (UTC-08:00) Pacific Time (US & Canada)
windowsdomain: WORKGROUP
productname: VMware Virtual Platform
defaultencoding: cp1252
defaultlanguage: en_US
biosversion: PhoenixBIOS 4.0 Release 6.0
osfullname: Microsoft Windows Server 2008 R2 Standard
osmanufacturer: Microsoft Corporation
manufacturer: VMware, Inc.
```

This is exactly the same data returned by the previous implementation in my testing (save for the re-appropriated locale grain)

This introduces a new runtime dependency for Windows through the ```wmi``` module. I've done my best to make sure that it gets included in the ```setup.py``` requirements, but it's kind of a hack. If there are better solutions for platform-specific dependencies, please let me know.