# Buggy code
def update(self):
    """Update IP stats using the input method.

    Stats is dict
    """
    # Reset stats
    self.reset()

    if self.input_method == "local" and netifaces_tag:
        # Update stats using the netifaces lib
        try:
            default_gw = netifaces.gateways()["default"][netifaces.AF_INET]
        except KeyError:
            logger.debug("Can not grab the default gateway")
        else:
            try:
                self.stats["address"] = netifaces.ifaddresses(default_gw[1])[
                    netifaces.AF_INET
                ][0]["addr"]
                self.stats["mask"] = netifaces.ifaddresses(default_gw[1])[
                    netifaces.AF_INET
                ][0]["netmask"]
                self.stats["mask_cidr"] = self.ip_to_cidr(self.stats["mask"])
                self.stats["gateway"] = netifaces.gateways()["default"][
                    netifaces.AF_INET
                ][0]
            except KeyError as e:
                logger.debug("Can not grab IP information (%s)".format(e))

    elif self.input_method == "snmp":
        # Not implemented yet
        pass

    # Update the view
    self.update_views()

    return self.stats


# Traceback (AttributeError)
raudenaerde@roba-ubuntu:~/$ sudo glances
Traceback (most recent call last):
File "/usr/local/bin/glances", line 9, in
load_entry_point('Glances==2.4.2', 'console_scripts', 'glances')()
File "/usr/local/lib/python2.7/dist-packages/glances/init.py", line 122, in main
args=core.get_args())
File "/usr/local/lib/python2.7/dist-packages/glances/core/glances_standalone.py", line 68, in init
self.stats.update()
File "/usr/local/lib/python2.7/dist-packages/glances/core/glances_stats.py", line 156, in update
self._plugins[p].update()
File "/usr/local/lib/python2.7/dist-packages/glances/plugins/glances_plugin.py", line 646, in wrapper
ret = fct(args, *kw)
File "/usr/local/lib/python2.7/dist-packages/glances/plugins/glances_ip.py", line 67, in update
default_gw = netifaces.gateways()['default'][netifaces.AF_INET]
AttributeError: 'module' object has no attribute 'gateways'

# Fixed code
def update(self):
    """Update IP stats using the input method.

    Stats is dict
    """
    # Reset stats
    self.reset()

    if self.input_method == "local" and netifaces_tag:
        # Update stats using the netifaces lib
        try:
            default_gw = netifaces.gateways()["default"][netifaces.AF_INET]
        except (KeyError, AttributeError) as e:
            logger.debug("Can not grab the default gateway ({})".format(e))
        else:
            try:
                self.stats["address"] = netifaces.ifaddresses(default_gw[1])[
                    netifaces.AF_INET
                ][0]["addr"]
                self.stats["mask"] = netifaces.ifaddresses(default_gw[1])[
                    netifaces.AF_INET
                ][0]["netmask"]
                self.stats["mask_cidr"] = self.ip_to_cidr(self.stats["mask"])
                self.stats["gateway"] = netifaces.gateways()["default"][
                    netifaces.AF_INET
                ][0]
            except (KeyError, AttributeError) as e:
                logger.debug("Can not grab IP information (%s)".format(e))

    elif self.input_method == "snmp":
        # Not implemented yet
        pass

    # Update the view
    self.update_views()

    return self.stats