# Buggy code
def __init__(self):
    """Init sensors stats."""
    # Temperatures
    self.init_temp = False
    self.stemps = {}
    try:
        # psutil>=5.1.0 is required
        self.stemps = psutil.sensors_temperatures()
    except AttributeError:
        logger.warning("Temperature sensors are only available on Linux")
        logger.warning("PsUtil 5.1.0 or higher is needed to grab temperatures sensors")
    except OSError as e:
        # FreeBSD: If oid 'hw.acpi.battery' not present, Glances wont start #1055
        logger.error("Can not grab temperatures sensors ({})".format(e))
    else:
        self.init_temp = True

    # Fans
    self.init_fan = False
    self.sfans = {}
    try:
        # psutil>=5.2.0 is required
        self.sfans = psutil.sensors_fans()
    except AttributeError:
        logger.warning("Fan speed sensors are only available on Linux")
        logger.warning("PsUtil 5.2.0 or higher is needed to grab fans sensors")
    except OSError as e:
        logger.error("Can not grab fans sensors ({})".format(e))
    else:
        self.init_fan = True

    # !!! Disable Fan: High CPU consumption with PSUtil 5.2.0 or higher
    # Delete the two followings lines when corrected (https://github.com/giampaolo/psutil/issues/1199)
    self.init_fan = False
    logger.debug(
        "Fan speed sensors disable (see https://github.com/giampaolo/psutil/issues/1199)"
    )

    # Init the stats
    self.reset()


# Traceback (OSError)
Traceback (most recent call last):
File "/usr/local/bin/glances", line 11, in <module>
load_entry_point('Glances==2.8.8', 'console_scripts', 'glances')()
File "/usr/local/lib/python2.7/site-packages/glances/__init__.py", line 225, in main
start_standalone(config=config, args=args)
File "/usr/local/lib/python2.7/site-packages/glances/__init__.py", line 105, in start_standalone
standalone = GlancesStandalone(config=config, args=args)
File "/usr/local/lib/python2.7/site-packages/glances/standalone.py", line 43, in __init__
self.stats = GlancesStats(config=config, args=args)
File "/usr/local/lib/python2.7/site-packages/glances/stats.py", line 43, in __init__
self.load_modules(self.args)
File "/usr/local/lib/python2.7/site-packages/glances/stats.py", line 77, in load_modules
self.load_plugins(args=args)
File "/usr/local/lib/python2.7/site-packages/glances/stats.py", line 96, in load_plugins
plugin = __import__(os.path.basename(item)[:-3])
File "/usr/local/lib/python2.7/site-packages/glances/plugins/glances_batpercent.py", line 38, in <module>
psutil.sensors_battery()
File "/usr/local/lib/python2.7/site-packages/psutil/__init__.py", line 2263, in sensors_battery
return _psplatform.sensors_battery()
File "/usr/local/lib/python2.7/site-packages/psutil/_psbsd.py", line 411, in sensors_battery
percent, minsleft, power_plugged = cext.sensors_battery()
OSError: [Errno 2] No such file or directory

# Fixed code
def __init__(self):
    """Init sensors stats."""
    # Temperatures
    self.init_temp = False
    self.stemps = {}
    try:
        # psutil>=5.1.0, Linux-only
        self.stemps = psutil.sensors_temperatures()
    except AttributeError:
        logger.debug("Cannot grab temperatures. Platform not supported.")
    else:
        self.init_temp = True

    # Fans
    self.init_fan = False
    self.sfans = {}
    try:
        # psutil>=5.2.0, Linux-only
        self.sfans = psutil.sensors_fans()
    except AttributeError:
        logger.debug("Cannot grab fans speed. Platform not supported.")
    else:
        self.init_fan = True

    # !!! Disable Fan: High CPU consumption with PSUtil 5.2.0 or higher
    # Delete the two followings lines when corrected (https://github.com/giampaolo/psutil/issues/1199)
    self.init_fan = False
    logger.debug(
        "Fan speed sensors disable (see https://github.com/giampaolo/psutil/issues/1199)"
    )

    # Init the stats
    self.reset()