Skip to content

Commit

Permalink
Fixes #15
Browse files Browse the repository at this point in the history
* add another plead to powershell to output utf8
* surpress the UnicodeDecodeError, just replace everything that cannot be decoded
  • Loading branch information
ueffel committed Jan 25, 2024
1 parent b0a66ba commit 19470c4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,14 @@ def __init__(self, execution=None, display_name=None, description=None, icon_pat
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
output, err = subprocess.Popen(["powershell.exe",
"-noprofile",
"chcp 65001 >$null; Get-AppxPackage | ConvertTo-Json"],
"chcp 65001 >$null; [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new(); Get-AppxPackage | ConvertTo-Json"],
stdout=subprocess.PIPE,
universal_newlines=False,
shell=False,
startupinfo=startupinfo).communicate()

catalog = []
packages = json.loads(output.decode("utf8"))
packages = json.loads(output.decode("utf8", "replace"))
for package in packages:
p = AppXPackage(package)
apps = p.apps()
Expand Down
4 changes: 2 additions & 2 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",
"chcp 65001 >$null; Get-AppxPackage | ConvertTo-Json"],
"chcp 65001 >$null; [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new(); Get-AppxPackage | ConvertTo-Json"],
stdout=subprocess.PIPE,
universal_newlines=False,
shell=False,
startupinfo=startupinfo).communicate()

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

0 comments on commit 19470c4

Please sign in to comment.