mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
[scripts/welcome] fix crash on newer Android versions where /proc/stat is inaccessible
This commit is contained in:
parent
b4acbcf006
commit
e2ebbccb2e
1 changed files with 9 additions and 3 deletions
|
@ -48,7 +48,9 @@ def get_system_info():
|
|||
|
||||
info_lines.append("")
|
||||
|
||||
info("CPU Usage", "%s", _get_cpu_usage())
|
||||
cpu_usage_info = _get_cpu_usage()
|
||||
if cpu_usage_info is not None:
|
||||
info("CPU Usage", "%s", cpu_usage_info)
|
||||
info("Memory", "%s / %s (%s)", *_get_memory())
|
||||
|
||||
for disk_info in _get_disks():
|
||||
|
@ -109,7 +111,11 @@ def _get_shell():
|
|||
|
||||
|
||||
def _get_cpu_usage():
|
||||
try:
|
||||
percent = psutil.cpu_percent()
|
||||
except Exception as e:
|
||||
print("Error in _get_cpu_usage:", e)
|
||||
return None
|
||||
|
||||
return colorize_percent(percent, warning=60, critical=80)
|
||||
|
||||
|
@ -153,7 +159,7 @@ def _get_battery():
|
|||
try:
|
||||
battery = psutil.sensors_battery()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print("Error in _get_battery:", e)
|
||||
return None
|
||||
|
||||
if battery is None:
|
||||
|
|
Loading…
Reference in a new issue