Add files via upload
This commit is contained in:
1 parent
c267bb198e
commit
5cb09eb813
1 file changed
+18
-4
+18
-4
@@ -108,16 +108,30 @@ def get_cpu_info():
|
|||||||
|
|
||||||
def get_disk_info():
|
def get_disk_info():
|
||||||
disk_info = []
|
disk_info = []
|
||||||
partitions = psutil.disk_partitions()
|
partitions = psutil.disk_partitions(all=True)
|
||||||
for p in partitions:
|
for p in partitions:
|
||||||
try:
|
try:
|
||||||
usage = psutil.disk_usage(p.mountpoint)
|
usage = psutil.disk_usage(p.mountpoint)
|
||||||
disk_info.append(
|
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}"
|
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:
|
except Exception as e:
|
||||||
# Handle the case where the drive is locked or inaccessible
|
# Handle various types of errors
|
||||||
disk_info.append(f"Drive: {p.device} | Inaccessible or locked")
|
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
|
return disk_info
|
||||||
|
|
||||||
def is_port_in_use(port):
|
def is_port_in_use(port):
|
||||||
|
|||||||
Reference in new issue
Block a user