battery_level: fix case when an invalid battery is detected (#1751)
battery_level: fix case when an invalid battery is detected (#1751)

battery_level module may return an error "list index out of range" in
the following situation:

- A system without battery (desktop)
- Connect a device that includes a battery and reports it status back
to Linux (a PS4 controller)

In this case, "/sys/class/power_supply/" exists, so the old check in
battery_level() pass. However _extract_battery_information_from_sys()
returns an empty list (since PS4 controller is not a battery),
making the rest of the code fail.

This commit changes the logic in battery_level() to check for an empty
list instead, and moves the "/sys/class/power_supply/" test inside
_extract_battery_information_from_sys().

It also allows _extract_battery_information_from_acpi() to run even
when "/sys/class/power_supply/" does not exists, however this seems to
be fine since ACPI can use other methods to check the battery level.
Andrwe/py3status,ultrabug/py3status,Andrwe/py3status,valdur55/py3status,ultrabug/py3status,valdur55/py3status,ultrabug/py3status,valdur55/py3status