Skip to content

Commit

Permalink
fix code page error in non-English systems
Browse files Browse the repository at this point in the history
  • Loading branch information
timsu92 authored and totaam committed Feb 15, 2025
1 parent 6998475 commit 7fd24b7
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions fs/bin/add_build_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import datetime
import shutil
from subprocess import Popen, PIPE, STDOUT
from subprocess import Popen, PIPE, STDOUT, run
import socket
import platform
import os.path
Expand Down Expand Up @@ -224,11 +224,18 @@ def get_platform_name() -> str:
return "OpenBSD"
if sys.platform.startswith("win"):
try:
out = Popen('systeminfo', stdout=PIPE, text=True).communicate()[0]
match = re.search(r"OS Name:\s*(.*)", out)
if match:
return match.group(1).strip()
return "Windows unknown"
out = run(
[
"powershell",
"-NoProfile",
"-Command",
"$OutputEncoding = [Console]::OutputEncoding = New-Object System.Text.UTF8Encoding; (Get-CimInstance Win32_OperatingSystem).Caption | Out-String",
],
capture_output=True,
text=True,
encoding="utf-8",
).stdout.strip()
return out
except OSError:
pass
return "Microsoft Windows"
Expand Down

0 comments on commit 7fd24b7

Please sign in to comment.