[debian] fix: displaying wrong symbols among numbers in transaction outputs for systems without english encoding installed

This commit is contained in:
Vinicius Moreira
2022-04-07 12:42:49 -03:00
parent 6d29da6373
commit 8cea0318ac
3 changed files with 14 additions and 5 deletions

View File

@@ -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)

View File

@@ -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):

View File

@@ -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': {