Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,9 +1471,13 @@ def multi_bcat(*paths):
except ValueError:
return ret.strip()
return None
# The final check verifies if the reported battery is internal
# since the existence of the device/path file represent an available
# ACPI path to the battery itself.
bats = [x for x in os.listdir(POWER_SUPPLY_PATH) if x.startswith('BAT')
or 'battery' in x.lower() and
os.path.exists(os.path.join(POWER_SUPPLY_PATH, x, "device/path"))]

bats = [x for x in os.listdir(POWER_SUPPLY_PATH) if x.startswith('BAT') or
'battery' in x.lower()]
if not bats:
return None
# Get the first available battery. Usually this is "BAT0", except
Expand Down