diff --git a/src/spl_core/common/command_line_executor.py b/src/spl_core/common/command_line_executor.py index 7b29aa2..62e6ff3 100644 --- a/src/spl_core/common/command_line_executor.py +++ b/src/spl_core/common/command_line_executor.py @@ -1,4 +1,6 @@ +import locale import subprocess +import sys from pathlib import Path from typing import Dict, List, Optional @@ -42,6 +44,7 @@ def execute(self, cmd: str | List[str]) -> subprocess.CompletedProcess[str]: text=True, env=self.env, universal_newlines=True, + encoding="cp850" if (locale.getlocale()[0] == "de_DE" and sys.platform == "win32") else "utf-8", ) as process: if process.stdout: for line in process.stdout: diff --git a/tests/unit/test_command_line_executor.py b/tests/unit/test_command_line_executor.py index 8d4b544..b580aba 100644 --- a/tests/unit/test_command_line_executor.py +++ b/tests/unit/test_command_line_executor.py @@ -1,3 +1,5 @@ +from pathlib import Path + import pytest from spl_core.common.command_line_executor import CommandLineExecutor @@ -29,3 +31,10 @@ def test_CommandLineExecuter(self, command, exp_stdout, exp_stderr, exp_returnco assert result.stdout == exp_stdout assert result.stderr == exp_stderr assert result.returncode == exp_returncode + + def test_CommandLineExecuter_exception(self, tmp_path: Path) -> None: + test_path = tmp_path.joinpath("test") + test_path.mkdir() + link_path = test_path.joinpath("link") + result = CommandLineExecutor().execute(["cmd", "/c", "mklink", "/J", str(link_path), str(test_path)]) + assert result.returncode == 0