Add files via upload

This commit is contained in:
erew123 authored and GitHub committed 2024-08-28 12:59:28 +01:00
1 parent c267bb198e
commit 5cb09eb813
1 file changed
+18 -4
+18 -4
View File
@@ -108,16 +108,30 @@ def get_cpu_info():
def get_disk_info():
disk_info = []
partitions = psutil.disk_partitions()
partitions = psutil.disk_partitions(all=True)
for p in partitions:
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")
except Exception as e:
# Handle various types of errors
error_type = type(e).__name__
error_message = str(e)
if isinstance(e, PermissionError):
status = "Inaccessible or locked (Permission denied)"
elif isinstance(e, OSError):
if e.winerror == 1117: # WinError 1117: I/O device error
status = "I/O device error"
else:
status = f"OS Error: {error_message}"
else:
status = f"Error: {error_type} - {error_message}"
disk_info.append(f"Drive: {p.device} | Status: {status} | Type: {p.fstype}")
return disk_info
def is_port_in_use(port):