Skip to content

Commit

Permalink
Fixes #12
Browse files Browse the repository at this point in the history
* force the powershell to output utf8
* don't go into text mode with subprocess.Popen (universal_newlines=False) because it will fail to decode the output
* decode the output of the powershell command explicitly
  • Loading branch information
ueffel committed Jan 29, 2021
1 parent 2560a87 commit f58606d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions windowsapps.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ def on_catalog(self):
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
output, err = subprocess.Popen(["powershell.exe",
"-noprofile",
"Get-AppxPackage | ConvertTo-Json"],
"chcp 65001 >$null; Get-AppxPackage | ConvertTo-Json"],
stdout=subprocess.PIPE,
universal_newlines=True,
universal_newlines=False,
shell=False,
startupinfo=startupinfo).communicate()

catalog = []
packages = json.loads(output)
packages = json.loads(output.decode("utf8"))
for package in packages:
try:
catalog.extend(self._create_catalog_item(package))
Expand Down

0 comments on commit f58606d

Please sign in to comment.