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

    Stats is a list of dict (one dict per interface)
    """
    # Reset stats
    self.reset()

    if self.input_method == "local":
        # Update stats using the standard system lib

        # Grab network interface stat using the PsUtil net_io_counter method
        try:
            netiocounters = psutil.net_io_counters(pernic=True)
        except UnicodeDecodeError:
            return self.stats

        # New in PsUtil 3.0: optionaly import the interface's status (issue #765)
        netstatus = {}
        try:
            netstatus = psutil.net_if_stats()
        except AttributeError:
            pass

        # Previous network interface stats are stored in the network_old variable
        if not hasattr(self, "network_old"):
            # First call, we init the network_old var
            try:
                self.network_old = netiocounters
            except (IOError, UnboundLocalError):
                pass
        else:
            # By storing time data we enable Rx/s and Tx/s calculations in the
            # XML/RPC API, which would otherwise be overly difficult work
            # for users of the API
            time_since_update = getTimeSinceLastUpdate("net")

            # Loop over interfaces
            network_new = netiocounters
            for net in network_new:
                # Do not take hidden interface into account
                if self.is_hide(net):
                    continue
                try:
                    cumulative_rx = network_new[net].bytes_recv
                    cumulative_tx = network_new[net].bytes_sent
                    cumulative_cx = cumulative_rx + cumulative_tx
                    rx = cumulative_rx - self.network_old[net].bytes_recv
                    tx = cumulative_tx - self.network_old[net].bytes_sent
                    cx = rx + tx
                    netstat = {
                        "interface_name": net,
                        "time_since_update": time_since_update,
                        "cumulative_rx": cumulative_rx,
                        "rx": rx,
                        "cumulative_tx": cumulative_tx,
                        "tx": tx,
                        "cumulative_cx": cumulative_cx,
                        "cx": cx,
                    }
                except KeyError:
                    continue
                else:
                    # Optional stats (only compliant with PsUtil 3.0+)
                    try:
                        netstat["is_up"] = netstatus[net].isup
                    except (KeyError, AttributeError):
                        pass
                    # Set the key
                    netstat["key"] = self.get_key()
                    self.stats.append(netstat)

            # Save stats to compute next bitrate
            self.network_old = network_new

    elif self.input_method == "snmp":
        # Update stats using SNMP

        # SNMP bulk command to get all network interface in one shot
        try:
            netiocounters = self.get_stats_snmp(
                snmp_oid=snmp_oid[self.short_system_name], bulk=True
            )
        except KeyError:
            netiocounters = self.get_stats_snmp(snmp_oid=snmp_oid["default"], bulk=True)

        # Previous network interface stats are stored in the network_old variable
        if not hasattr(self, "network_old"):
            # First call, we init the network_old var
            try:
                self.network_old = netiocounters
            except (IOError, UnboundLocalError):
                pass
        else:
            # See description in the 'local' block
            time_since_update = getTimeSinceLastUpdate("net")

            # Loop over interfaces
            network_new = netiocounters

            for net in network_new:
                # Do not take hidden interface into account
                if self.is_hide(net):
                    continue

                try:
                    # Windows: a tips is needed to convert HEX to TXT
                    # http://blogs.technet.com/b/networking/archive/2009/12/18/how-to-query-the-list-of-network-interfaces-using-snmp-via-the-ifdescr-counter.aspx
                    if self.short_system_name == "windows":
                        try:
                            interface_name = str(base64.b16decode(net[2:-2].upper()))
                        except TypeError:
                            interface_name = net
                    else:
                        interface_name = net

                    cumulative_rx = float(network_new[net]["cumulative_rx"])
                    cumulative_tx = float(network_new[net]["cumulative_tx"])
                    cumulative_cx = cumulative_rx + cumulative_tx
                    rx = cumulative_rx - float(self.network_old[net]["cumulative_rx"])
                    tx = cumulative_tx - float(self.network_old[net]["cumulative_tx"])
                    cx = rx + tx
                    netstat = {
                        "interface_name": interface_name,
                        "time_since_update": time_since_update,
                        "cumulative_rx": cumulative_rx,
                        "rx": rx,
                        "cumulative_tx": cumulative_tx,
                        "tx": tx,
                        "cumulative_cx": cumulative_cx,
                        "cx": cx,
                    }
                except KeyError:
                    continue
                else:
                    netstat["key"] = self.get_key()
                    self.stats.append(netstat)

            # Save stats to compute next bitrate
            self.network_old = network_new

    # Update the history list
    self.update_stats_history(self.get_key())

    # Update the view
    self.update_views()

    return self.stats


# Traceback (PermissionError)
$ lsb_release -a
LSB Version:    :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: Scientific
Description:    Scientific Linux release 6.3 (Carbon)
Release:    6.3
Codename:   Carbon
$ glances -V
Glances v2.6.2 with psutil v4.3.0
$ glances
Traceback (most recent call last):
File "/groups/dudman/home/kirkhamj/miniconda/envs/nanshenv3/bin/glances", line 6, in <module>
sys.exit(glances.main())
File "/groups/dudman/home/kirkhamj/miniconda/envs/nanshenv3/lib/python3.5/site-packages/glances/__init__.py", line 130, in main
args=core.get_args())
File "/groups/dudman/home/kirkhamj/miniconda/envs/nanshenv3/lib/python3.5/site-packages/glances/standalone.py", line 67, in __init__
self.stats.update()
File "/groups/dudman/home/kirkhamj/miniconda/envs/nanshenv3/lib/python3.5/site-packages/glances/stats.py", line 154, in update
self._plugins[p].update()
File "/groups/dudman/home/kirkhamj/miniconda/envs/nanshenv3/lib/python3.5/site-packages/glances/plugins/glances_plugin.py", line 658, in wrapper
ret = fct(*args, **kw)
File "/groups/dudman/home/kirkhamj/miniconda/envs/nanshenv3/lib/python3.5/site-packages/glances/plugins/glances_network.py", line 90, in update
netstatus = psutil.net_if_stats()
File "/groups/dudman/home/kirkhamj/miniconda/envs/nanshenv3/lib/python3.5/site-packages/psutil/__init__.py", line 1961, in net_if_stats
return _psplatform.net_if_stats()
File "/groups/dudman/home/kirkhamj/miniconda/envs/nanshenv3/lib/python3.5/site-packages/psutil/_pslinux.py", line 791, in net_if_stats
isup, duplex, speed, mtu = cext.net_if_stats(name)
PermissionError: [Errno 1] Operation not permitted

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

    Stats is a list of dict (one dict per interface)
    """
    # Reset stats
    self.reset()

    if self.input_method == "local":
        # Update stats using the standard system lib

        # Grab network interface stat using the PsUtil net_io_counter method
        try:
            netiocounters = psutil.net_io_counters(pernic=True)
        except UnicodeDecodeError:
            return self.stats

        # New in PsUtil 3.0: optionaly import the interface's status (issue #765)
        netstatus = {}
        try:
            netstatus = psutil.net_if_stats()
        except:
            pass

        # Previous network interface stats are stored in the network_old variable
        if not hasattr(self, "network_old"):
            # First call, we init the network_old var
            try:
                self.network_old = netiocounters
            except (IOError, UnboundLocalError):
                pass
        else:
            # By storing time data we enable Rx/s and Tx/s calculations in the
            # XML/RPC API, which would otherwise be overly difficult work
            # for users of the API
            time_since_update = getTimeSinceLastUpdate("net")

            # Loop over interfaces
            network_new = netiocounters
            for net in network_new:
                # Do not take hidden interface into account
                if self.is_hide(net):
                    continue
                try:
                    cumulative_rx = network_new[net].bytes_recv
                    cumulative_tx = network_new[net].bytes_sent
                    cumulative_cx = cumulative_rx + cumulative_tx
                    rx = cumulative_rx - self.network_old[net].bytes_recv
                    tx = cumulative_tx - self.network_old[net].bytes_sent
                    cx = rx + tx
                    netstat = {
                        "interface_name": net,
                        "time_since_update": time_since_update,
                        "cumulative_rx": cumulative_rx,
                        "rx": rx,
                        "cumulative_tx": cumulative_tx,
                        "tx": tx,
                        "cumulative_cx": cumulative_cx,
                        "cx": cx,
                    }
                except KeyError:
                    continue
                else:
                    # Optional stats (only compliant with PsUtil 3.0+)
                    try:
                        netstat["is_up"] = netstatus[net].isup
                    except (KeyError, AttributeError):
                        pass
                    # Set the key
                    netstat["key"] = self.get_key()
                    self.stats.append(netstat)

            # Save stats to compute next bitrate
            self.network_old = network_new

    elif self.input_method == "snmp":
        # Update stats using SNMP

        # SNMP bulk command to get all network interface in one shot
        try:
            netiocounters = self.get_stats_snmp(
                snmp_oid=snmp_oid[self.short_system_name], bulk=True
            )
        except KeyError:
            netiocounters = self.get_stats_snmp(snmp_oid=snmp_oid["default"], bulk=True)

        # Previous network interface stats are stored in the network_old variable
        if not hasattr(self, "network_old"):
            # First call, we init the network_old var
            try:
                self.network_old = netiocounters
            except (IOError, UnboundLocalError):
                pass
        else:
            # See description in the 'local' block
            time_since_update = getTimeSinceLastUpdate("net")

            # Loop over interfaces
            network_new = netiocounters

            for net in network_new:
                # Do not take hidden interface into account
                if self.is_hide(net):
                    continue

                try:
                    # Windows: a tips is needed to convert HEX to TXT
                    # http://blogs.technet.com/b/networking/archive/2009/12/18/how-to-query-the-list-of-network-interfaces-using-snmp-via-the-ifdescr-counter.aspx
                    if self.short_system_name == "windows":
                        try:
                            interface_name = str(base64.b16decode(net[2:-2].upper()))
                        except TypeError:
                            interface_name = net
                    else:
                        interface_name = net

                    cumulative_rx = float(network_new[net]["cumulative_rx"])
                    cumulative_tx = float(network_new[net]["cumulative_tx"])
                    cumulative_cx = cumulative_rx + cumulative_tx
                    rx = cumulative_rx - float(self.network_old[net]["cumulative_rx"])
                    tx = cumulative_tx - float(self.network_old[net]["cumulative_tx"])
                    cx = rx + tx
                    netstat = {
                        "interface_name": interface_name,
                        "time_since_update": time_since_update,
                        "cumulative_rx": cumulative_rx,
                        "rx": rx,
                        "cumulative_tx": cumulative_tx,
                        "tx": tx,
                        "cumulative_cx": cumulative_cx,
                        "cx": cx,
                    }
                except KeyError:
                    continue
                else:
                    netstat["key"] = self.get_key()
                    self.stats.append(netstat)

            # Save stats to compute next bitrate
            self.network_old = network_new

    # Update the history list
    self.update_stats_history(self.get_key())

    # Update the view
    self.update_views()

    return self.stats