# Buggy code
def __update__(self):
    """Update the stats."""
    # Reset the list
    self.reset()

    # Only update if --disable-hddtemp is not set
    if self.args is None or self.args.disable_hddtemp:
        return

    # Fetch the data
    data = self.fetch()

    # Exit if no data
    if data == "":
        return

    # Safety check to avoid malformed data
    # Considering the size of "|/dev/sda||0||" as the minimum
    if len(data) < 14:
        data = self.cache if len(self.cache) > 0 else self.fetch()
    self.cache = data

    try:
        fields = data.split(b"|")
    except TypeError:
        fields = ""
    devices = (len(fields) - 1) // 5
    for item in range(devices):
        offset = item * 5
        hddtemp_current = {}
        device = os.path.basename(nativestr(fields[offset + 1]))
        temperature = fields[offset + 3]
        unit = nativestr(fields[offset + 4])
        hddtemp_current["label"] = device
        # Temperature could be 'ERR' or 'SLP' (see issue#824)
        hddtemp_current["value"] = (
            float(temperature)
            if isinstance(temperature, numbers.Number)
            else temperature
        )
        hddtemp_current["unit"] = unit
        self.hddtemp_list.append(hddtemp_current)


# Traceback (ValueError)
roger@MEGIDO:~$ glances -V
Glances v2.6.1 with psutil v4.1.0
roger@MEGIDO:~$ glances
Traceback (most recent call last):
File "/usr/local/bin/glances", line 9, in <module>
load_entry_point('Glances==2.6.1', 'console_scripts', 'glances')()
File "/usr/local/lib/python2.7/dist-packages/glances/__init__.py", line 130, in main
args=core.get_args())
File "/usr/local/lib/python2.7/dist-packages/glances/standalone.py", line 67, in __init__
self.stats.update()
File "/usr/local/lib/python2.7/dist-packages/glances/stats.py", line 154, in update
self._plugins[p].update()
File "/usr/local/lib/python2.7/dist-packages/glances/plugins/glances_hddtemp.py", line 62, in update
self.stats = self.glancesgrabhddtemp.get()
File "/usr/local/lib/python2.7/dist-packages/glances/plugins/glances_hddtemp.py", line 145, in get
self.__update__()
File "/usr/local/lib/python2.7/dist-packages/glances/plugins/glances_hddtemp.py", line 122, in __update__
hddtemp_current['value'] = float(temperature) if temperature != b'ERR' else temperature
ValueError: could not convert string to float: SLP
roger@MEGIDO:~$

# Fixed code
def __update__(self):
    """Update the stats."""
    # Reset the list
    self.reset()

    # Only update if --disable-hddtemp is not set
    if self.args is None or self.args.disable_hddtemp:
        return

    # Fetch the data
    # data = "|/dev/sda|WDC WD2500JS-75MHB0|44|C||/dev/sdb|WDC WD2500JS-75MHB0|35|C||/dev/sdc|WDC WD3200AAKS-75B3A0|45|C||/dev/sdd|WDC WD3200AAKS-75B3A0|45|C||/dev/sde|WDC WD3200AAKS-75B3A0|43|C||/dev/sdf|SAMSUNG HM321HI|39|C||/dev/sdg|HGST HTS541010A9E680|SLP|*|"
    data = self.fetch()

    # Exit if no data
    if data == "":
        return

    # Safety check to avoid malformed data
    # Considering the size of "|/dev/sda||0||" as the minimum
    if len(data) < 14:
        data = self.cache if len(self.cache) > 0 else self.fetch()
    self.cache = data

    try:
        fields = data.split(b"|")
    except TypeError:
        fields = ""
    devices = (len(fields) - 1) // 5
    for item in range(devices):
        offset = item * 5
        hddtemp_current = {}
        device = os.path.basename(nativestr(fields[offset + 1]))
        temperature = fields[offset + 3]
        unit = nativestr(fields[offset + 4])
        hddtemp_current["label"] = device
        try:
            hddtemp_current["value"] = float(temperature)
        except ValueError:
            # Temperature could be 'ERR' or 'SLP' (see issue#824)
            hddtemp_current["value"] = temperature
        hddtemp_current["unit"] = unit
        self.hddtemp_list.append(hddtemp_current)