That would seem to be the only way to do it:
import platform
osname = platform.platform()
if osname.startswith('Windows'):
elif osname.startswith('Linux'):
else:
print(osname, ' is not a valid OS')
The OS names I get on my systems are:
Windows-10-10.0.19045-SP0
and
Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29
[edit]
According to the documentation
platform.system()
returns the bas system name, i.e. 'Windows' or 'Linux'.
[/edit]
[edit version="2"]
You could also make this tidier by creating external modules with the code for finding the disk information. As long as each module returns the data in exactly the same format, you could do something like:
import platform
osname = platform.system()
if osname == 'Windows':
import windisks as dinfo
elif osname.startswith('Linux'):
import linuxdisks as dinfo
else:
print(osname, ' is not a valid OS')
diskinfo = dinfo.getinfo()
[/edit]