Skip to content

Commit 0e5b604

Browse files
wmvanvlietsseth
authored andcommitted
Make mne.sys_info() work with powershell 7+ (mne-tools#13593)
1 parent 093495e commit 0e5b604

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

doc/changes/dev/13593.other.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
make :func:`mne.sys_info` work on Windows systems with Powershell version 7+, by `Marijn van Vliet`_

mne/utils/config.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -681,11 +681,9 @@ def _get_gpu_info():
681681
def _get_total_memory():
682682
"""Return the total memory of the system in bytes."""
683683
if platform.system() == "Windows":
684+
ps = shutil.which("pwsh") or shutil.which("powershell")
684685
o = subprocess.check_output(
685-
[
686-
"powershell.exe",
687-
"(Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory",
688-
]
686+
[ps, "-c", "(Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory"]
689687
).decode()
690688
# Can get for example a "running scripts is disabled on this system"
691689
# error where "o" will be a long string rather than an int
@@ -708,8 +706,9 @@ def _get_total_memory():
708706
def _get_cpu_brand():
709707
"""Return the CPU brand string."""
710708
if platform.system() == "Windows":
709+
ps = shutil.which("pwsh") or shutil.which("powershell")
711710
o = subprocess.check_output(
712-
["powershell.exe", "(Get-CimInstance Win32_Processor).Name"]
711+
[ps, "-c", "(Get-CimInstance Win32_Processor).Name"]
713712
).decode()
714713
cpu_brand = o.strip().splitlines()[-1]
715714
elif platform.system() == "Linux":

0 commit comments

Comments
 (0)