linuxmint / mintreport

Troubleshooting tool
19 stars 18 forks source link

MintReport not able to list system information on Thinkpad L15 due to UTF-8 error #72

Closed dead-flunky closed 1 year ago

dead-flunky commented 3 years ago

mintreport/app/load_sysinfo fails due to a non-UTF-8 character in the name of battery (\xc0) as returned by subprocess.check_output.

System: Kernel: 5.8.0-50-generic x86_64 bits: 64 compiler: N/A Desktop: Cinnamon 4.8.6 wm: muffin dm: LightDM Distro: Linux Mint 20.1 Ulyssa base: Ubuntu 20.04 focal Machine: Type: Laptop System: LENOVO product: 20U8S0AH00 v: ThinkPad L15 Gen 1 serial: Chassis: type: 10 serial: Mobo: LENOVO model: 20U8S0AH00 serial: UEFI: LENOVO v: R19ET32W (1.16 ) date: 01/26/2021 Battery: ID-1: BAT0 charge: 45.6 Wh condition: 48.1/45.3 Wh (106%) volts: 12.4/11.1 model: SMP LNV-5B10W13895\xc0\xc0 serial: status: Unknown

Workaround: add optional parameter errors='replace' or errors='backslashreplace' to decode("UTF-8")

@_async
def load_sysinfo(self):
    try:
        sysinfo = subprocess.check_output("LANG=C inxi -Fxxrzc0 --usb", shell=True).decode("UTF-8",errors='backslashreplace')
        self.add_sysinfo_to_textview(sysinfo)
        with open(TMP_INXI_FILE, "w") as f:
            f.write(sysinfo)
    except Exception as e:
        subprocess.Popen(['notify-send', '-i', 'dialog-error-symbolic', _("An error occurred while gathering the system information."), str(e)])
        print (e)
steve4gith commented 1 year ago

This problem still exists in Linux Mint 21.2 (installed yesterday) and the above workaround works great but should be in the base code (IMHO) in /usr/lib/linuxmint/mintreport/app.py . Note that Linux Mint 21.1 has the same problem, as do prior Linux Mint versions, depending upon the Lenovo ThinkPad battery. ;-)

For my ThinkPad X13, without the above workaround, I have the same problem (Mint System Reports System information fails) with 2 special characters after the battery info. from inxi -Fxxrzc0 --usb .

Here's the fixed System Reports System information output:

Battery: ID-1: BAT0 charge: 49.0 Wh (89.6%) condition: 54.7/54.7 Wh (100.0%) volts: 15.8 min: 15.4 model: Sunwoda LNV-5B10W51855\xc0\xe0 serial: status: Not charging

Special thanks to dead-flunky for the report and workaround.