Added function drive_is_rotational()
This commit is contained in:
parent
9fc882533d
commit
ef0b2cbb58
1 changed files with 27 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
# Wizard Kit: Functions - Setup
|
||||
|
||||
from functions.browsers import *
|
||||
from functions.json import *
|
||||
from functions.update import *
|
||||
from settings.setup import *
|
||||
from settings.sources import *
|
||||
|
|
@ -403,6 +404,32 @@ def install_vcredists():
|
|||
|
||||
|
||||
# Misc
|
||||
def drive_is_rotational(drive):
|
||||
"""Check if drive is rotational, returns bool.
|
||||
|
||||
NOTE: This is a quick, naive check with a bias towards rotational."""
|
||||
is_rotational = True
|
||||
|
||||
# Get SMART data
|
||||
extract_item('smartmontools', silent=True)
|
||||
cmd = [
|
||||
global_vars['Tools']['smartctl'],
|
||||
'--info',
|
||||
'--json',
|
||||
drive,
|
||||
]
|
||||
data = get_json_from_command(cmd, check=False)
|
||||
|
||||
# Check rotation rate
|
||||
try:
|
||||
is_rotational = int(data.get('rotation_rate', '01189998819991197253')) == 0
|
||||
except ValueError:
|
||||
# Ignore and assume rotational
|
||||
pass
|
||||
|
||||
return is_rotational
|
||||
|
||||
|
||||
def open_device_manager():
|
||||
popen_program(['mmc', 'devmgmt.msc'])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue