'Update network stats using the input method.
Stats is a list of dict (one dict per interface)'

@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self):

    self.reset()
    if (self.input_method == 'local'):
        try:
            netiocounters = psutil.net_io_counters(pernic=True)
        except UnicodeDecodeError:
            return self.stats
        netstatus = {}
        try:
            netstatus = psutil.net_if_stats()
        except AttributeError:
            pass
        if (not hasattr(self, 'network_old')):
            try:
                self.network_old = netiocounters
            except (IOError, UnboundLocalError):
                pass
        else:
            time_since_update = getTimeSinceLastUpdate('net')
            network_new = netiocounters
            for net in network_new:
                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:
                    try:
                        netstat['is_up'] = netstatus[net].isup
                    except (KeyError, AttributeError):
                        pass
                    try:
                        netstat['speed'] = (netstatus[net].speed * 1048576)
                    except (KeyError, AttributeError):
                        pass
                    netstat['key'] = self.get_key()
                    self.stats.append(netstat)
            self.network_old = network_new
    elif (self.input_method == 'snmp'):
        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)
        if (not hasattr(self, 'network_old')):
            try:
                self.network_old = netiocounters
            except (IOError, UnboundLocalError):
                pass
        else:
            time_since_update = getTimeSinceLastUpdate('net')
            network_new = netiocounters
            for net in network_new:
                if self.is_hide(net):
                    continue
                try:
                    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)
            self.network_old = network_new
    return self.stats
