Skip to content

Commit

Permalink
Find boot mount point using psutil (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcapona authored May 29, 2024
1 parent c136964 commit 7a9f4ef
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions debian/py3dist-overrides
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ wget python3-wget; PEP386
pyzmq python3-zmq; PEP386
pygame python3-pygame; PEP386
xlib python3-xlib; PEP386
psutil python3-psutil; PEP386
19 changes: 18 additions & 1 deletion packages/common/pitop/common/pt_os.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
import logging
from dataclasses import dataclass
from getpass import getuser
from os import path

ptissue_path = "/boot/pt-issue.txt"
import psutil


def get_boot_partition_path():
try:
for partition in psutil.disk_partitions():
if (
partition.mountpoint.startswith("/boot")
and ".recovery" not in partition.mountpoint
):
return partition.mountpoint
except Exception as e:
logging.error(f"Couldn't find boot partition: {e}")
return ""


ptissue_path = f"{get_boot_partition_path()}/pt-issue.txt"
legacy_ptissue_path = "/etc/pt-issue"


Expand Down
2 changes: 2 additions & 0 deletions packages/common/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
"smbus2>=0.4.0,<1.0.0",
# Device Communication
"pyzmq>=20.0.0,<25.0.0",
# To determine boot partition mount point
"psutil",
]


Expand Down

0 comments on commit 7a9f4ef

Please sign in to comment.