work around locked drive letters

This commit is contained in:
erew123 authored and GitHub committed 2024-08-24 13:30:02 +01:00
1 parent 0a1a81a962
commit 4775d0db34
1 file changed
+8 -2
+8 -2
View File
@@ -110,8 +110,14 @@ def get_disk_info():
disk_info = []
partitions = psutil.disk_partitions()
for p in partitions:
usage = psutil.disk_usage(p.mountpoint)
disk_info.append(f" Drive: {p.device} | Total: {usage.total / (1024 ** 3):.2f} GB | Used: {usage.used / (1024 ** 3):.2f} GB | Free: {usage.free / (1024 ** 3):.2f} GB | Type: {p.fstype}")
try:
usage = psutil.disk_usage(p.mountpoint)
disk_info.append(
f"Drive: {p.device} | Total: {usage.total / (1024 ** 3):.2f} GB | Used: {usage.used / (1024 ** 3):.2f} GB | Free: {usage.free / (1024 ** 3):.2f} GB | Type: {p.fstype}"
)
except PermissionError:
# Handle the case where the drive is locked or inaccessible
disk_info.append(f"Drive: {p.device} | Inaccessible or locked")
return disk_info
def is_port_in_use(port):