Minor refractor
This commit is contained in:
@@ -48,6 +48,13 @@ class Drive:
|
|||||||
self.stat_filepath = stat_filepath
|
self.stat_filepath = stat_filepath
|
||||||
self.hddtemp_daemon_port = hddtemp_daemon_port
|
self.hddtemp_daemon_port = hddtemp_daemon_port
|
||||||
self.logger = logging.getLogger(str(self))
|
self.logger = logging.getLogger(str(self))
|
||||||
|
self.supports_hitachi_temp_query = self.supportsHitachiTempQuery()
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
""" Return a pretty drive name. """
|
||||||
|
return os.path.basename(self.device_filepath).rsplit("-", 1)[-1]
|
||||||
|
|
||||||
|
def supportsHitachiTempQuery(self):
|
||||||
# test if drive supports hdparm -H
|
# test if drive supports hdparm -H
|
||||||
cmd = ("hdparm", "-H", self.device_filepath)
|
cmd = ("hdparm", "-H", self.device_filepath)
|
||||||
try:
|
try:
|
||||||
@@ -57,13 +64,8 @@ class Drive:
|
|||||||
stderr=subprocess.DEVNULL)
|
stderr=subprocess.DEVNULL)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
self.logger.warning("Drive does not allow querying temperature without going out of low power mode.")
|
self.logger.warning("Drive does not allow querying temperature without going out of low power mode.")
|
||||||
self.supports_hitachi_temp_query = False
|
return False
|
||||||
else:
|
return True
|
||||||
self.supports_hitachi_temp_query = True
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
""" Return a pretty drive name. """
|
|
||||||
return os.path.basename(self.device_filepath).rsplit("-", 1)[-1]
|
|
||||||
|
|
||||||
def getState(self):
|
def getState(self):
|
||||||
""" Get drive power state, as a DriveState enum. """
|
""" Get drive power state, as a DriveState enum. """
|
||||||
|
|||||||
Reference in New Issue
Block a user