diff --git a/CHANGELOG.md b/CHANGELOG.md index d9c4f6e9..0580ee00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Debian - info: crashing when the package size has unexpected symbols [#251](https://github.com/vinifmor/bauh/issues/251) + - displaying wrong symbols among numbers in install/uninstall/upgrade outputs for systems without english encoding installed - UI - not displaying the right unit symbol for byte based sizes (kB, MB, TB, ...) [#250](https://github.com/vinifmor/bauh/issues/250) diff --git a/bauh/gems/debian/aptitude.py b/bauh/gems/debian/aptitude.py index 38457ebf..d9a7e20e 100644 --- a/bauh/gems/debian/aptitude.py +++ b/bauh/gems/debian/aptitude.py @@ -46,6 +46,7 @@ class Aptitude: self._default_lang = '' self._ignored_fields: Optional[Set[str]] = None self._re_none: Optional[Pattern] = None + self._vars_encoding_fix: Optional[Dict[str, str]] = None def show(self, pkgs: Iterable[str], attrs: Optional[Collection[str]] = None, verbose: bool = False) \ -> Optional[Dict[str, Dict[str, object]]]: @@ -128,7 +129,7 @@ class Aptitude: def upgrade(self, packages: Iterable[str], root_password: Optional[str]) -> SimpleProcess: cmd = self.gen_transaction_cmd('upgrade', packages).split(' ') - return SimpleProcess(cmd=cmd, shell=True, root_password=root_password) + return SimpleProcess(cmd=cmd, shell=True, root_password=root_password, extra_env=self.vars_encoding_fix) def update(self, root_password: Optional[str]) -> SimpleProcess: return SimpleProcess(('aptitude', 'update'), root_password=root_password, shell=True) @@ -142,7 +143,7 @@ class Aptitude: def install(self, packages: Iterable[str], root_password: Optional[str]) -> SimpleProcess: cmd = self.gen_transaction_cmd('install', packages).split(' ') - return SimpleProcess(cmd=cmd, shell=True, root_password=root_password) + return SimpleProcess(cmd=cmd, shell=True, root_password=root_password, extra_env=self.vars_encoding_fix) def read_installed(self) -> Generator[DebianPackage, None, None]: yield from self.search(query='~i') @@ -199,7 +200,7 @@ class Aptitude: def remove(self, packages: Iterable[str], root_password: Optional[str], purge: bool = False) -> SimpleProcess: return SimpleProcess(cmd=self.gen_remove_cmd(packages, purge).split(' '), shell=True, - root_password=root_password) + root_password=root_password, extra_env=self.vars_encoding_fix) def read_installed_names(self) -> Generator[str, None, None]: code, output = system.execute("aptitude search ~i -q -F '%p' --disable-columns", @@ -274,6 +275,13 @@ class Aptitude: return self._re_none + @property + def vars_encoding_fix(self) -> Dict[str, str]: + if self._vars_encoding_fix is None: + self._vars_encoding_fix = {'LC_NUMERIC': ''} + + return self._vars_encoding_fix + class AptitudeOutputHandler(Thread): diff --git a/tests/gems/debian/test_aptitude.py b/tests/gems/debian/test_aptitude.py index 0e3f3409..20ff9410 100644 --- a/tests/gems/debian/test_aptitude.py +++ b/tests/gems/debian/test_aptitude.py @@ -97,8 +97,8 @@ Description: GNU C compiler def test_show__all_attributes(self, execute: Mock): info = self.aptitude.show(('firefox', 'gcc')) execute.assert_called_once_with('aptitude show -q firefox gcc', shell=True, - custom_env=system.gen_env(global_interpreter=system.USE_GLOBAL_INTERPRETER, - lang='')) + custom_env={**system.gen_env(global_interpreter=system.USE_GLOBAL_INTERPRETER, + lang=''), 'LC_NUMERIC': ''}) expected = { 'firefox': {