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 16, 2025
1 parent 86ff7d3 commit 4816c2d
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 @@ -8,7 +8,7 @@
#pylint: disable=bare-except

import datetime
from subprocess import Popen, PIPE, STDOUT
from subprocess import Popen, PIPE, STDOUT, run
import socket
import platform
import os.path
Expand Down Expand Up @@ -200,11 +200,18 @@ def get_platform_name():
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 4816c2d

Please sign in to comment.