cesbit / aiowmi

Python WMI Queries
GNU General Public License v3.0
27 stars 8 forks source link

Zero integer values end up as None/null #9

Closed hege-li closed 2 years ago

hege-li commented 2 years ago

Describe the bug Query: Select * from Win32_UTCTime

Result when run at different seconds 59,0,1:

Year|Month|Day|DayOfWeek|WeekInMonth|Quarter|Hour|Minute|Second|Milliseconds 2022|6|17|5|3|2|11|32|59|(null) 2022|6|17|5|3|2|11|33|(null)|(null) 2022|6|17|5|3|2|11|33|1|(null)

As you see, Milliseconds is always None/null. When Second is 0, it ends up as None/null too.

Old wmic linux-binary shows them correctly as 0 (even Milliseconds which is "not implemented" according to Microsoft docs).

If using ignore_missing=True, Second/Milliseconds disappear completely from results.

To Reproduce

"""basic code from example, here is my print function"""
props = res.get_properties()
v = []
for name, prop in props.items():
    if prop.value is None:
        v.append('(null)')
    else:
        v.append(str(prop.value))
print('|'.join(v))

Expected behavior Value should be 0 instead of None/null

joente commented 2 years ago

This is fixed in v0.1.16. See commit https://github.com/cesbit/aiowmi/commit/3ecbd3e18fa96eec0605351ae9f31372be26ae9b

When using ignore_defaults=True it is still possible to get None value for missing properties but leaving ignore_defaults as False now sets default values, thus 0 for Milliseconds in the example.