Fix #101873: wmic not found on insider builds of Windows 11 #101874
@ -135,31 +135,57 @@ def _get_cpu_topology() -> CPUTopology:
|
|||||||
sockets = cores_info.get_physical_processors_count()
|
sockets = cores_info.get_physical_processors_count()
|
||||||
cores = cores_info.get_physical_cores_count()
|
cores = cores_info.get_physical_cores_count()
|
||||||
else:
|
else:
|
||||||
sockets = int(
|
if sys.getwindowsversion().major >= 10:
|
||||||
subprocess.check_output(
|
sockets = int(
|
||||||
(
|
subprocess.check_output(
|
||||||
'powershell',
|
(
|
||||||
'-Command',
|
'powershell',
|
||||||
'Get-CimInstance Win32_ComputerSystem | Select-Object -ExpandProperty NumberOfProcessors'
|
'-Command',
|
||||||
),
|
'Get-CimInstance Win32_ComputerSystem | Select-Object -ExpandProperty NumberOfProcessors'
|
||||||
text=True,
|
),
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
.strip()
|
||||||
)
|
)
|
||||||
.strip()
|
|
||||||
)
|
|
||||||
|
|
||||||
cores = sum(
|
cores = sum(
|
||||||
int(core) for core in subprocess.check_output(
|
int(core) for core in subprocess.check_output(
|
||||||
(
|
(
|
||||||
'powershell',
|
'powershell',
|
||||||
'-Command',
|
'-Command',
|
||||||
'Get-CimInstance Win32_Processor | Select-Object -ExpandProperty NumberOfCores'
|
'Get-CimInstance Win32_Processor | Select-Object -ExpandProperty NumberOfCores'
|
||||||
),
|
),
|
||||||
text=True
|
text=True
|
||||||
|
)
|
||||||
|
.strip()
|
||||||
|
.split('\n')
|
||||||
|
if core
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
sockets = int(
|
||||||
|
subprocess.check_output(
|
||||||
|
(
|
||||||
|
'wmic',
|
||||||
|
'computersystem',
|
||||||
|
'get',
|
||||||
|
'NumberOfProcessors',
|
||||||
|
'/value',
|
||||||
|
),
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
.strip()
|
||||||
|
.split('=')[1]
|
||||||
|
)
|
||||||
|
|
||||||
|
cores = sum(
|
||||||
|
int(line.strip().split('=')[1])
|
||||||
|
for line in subprocess.check_output(
|
||||||
|
('wmic', 'cpu', 'get', 'NumberOfCores', '/value'), text=True
|
||||||
|
)
|
||||||
|
.strip()
|
||||||
|
.split('\n')
|
||||||
|
if line.strip()
|
||||||
)
|
)
|
||||||
.strip()
|
|
||||||
.split('\n')
|
|
||||||
if core
|
|
||||||
)
|
|
||||||
|
|
||||||
return CPUTopology(sockets=sockets, cores=cores, threads=multiprocessing.cpu_count())
|
return CPUTopology(sockets=sockets, cores=cores, threads=multiprocessing.cpu_count())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user