[debian] fix: crashing when parsing the package size attributes with unexpected symbols (info dialog)

This commit is contained in:
Vinicius Moreira
2022-04-04 11:41:59 -03:00
parent 8efb83e94c
commit 9e2184a0e9
2 changed files with 14 additions and 3 deletions

View File

@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [0.10.2]
### Fixes
- Debian
- info: crashing when the package size has unexpected symbols [#251](https://github.com/vinifmor/bauh/issues/251)
## [0.10.1] 2022-03-31
### Features

View File

@@ -72,9 +72,14 @@ class Aptitude:
size_split = final_val.split(' ')
if len(size_split) >= 1:
number = float(size_split[0].replace(',', '.'))
measure = size_split[1].strip().lower() if len(size_split) >= 2 else 'b'
final_val = size_to_byte(number, measure)
try:
number = float(size_split[0].replace(',', '.'))
measure = size_split[1].strip().lower() if len(size_split) >= 2 else 'b'
final_val = size_to_byte(number, measure)
except ValueError:
self._log.warning(f"Could not parse the attribute '{final_field}' "
f"value {final_val} to float")
final_val = None
else:
self._log.warning(f"Unhandled value ({val}) for attribute '{field}'")
final_val = None