'Update disk I/O stats using the input method.'

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

    self.reset()
    if (self.input_method == 'local'):
        try:
            diskiocounters = psutil.disk_io_counters(perdisk=True)
        except Exception:
            return self.stats
        if (not hasattr(self, 'diskio_old')):
            try:
                self.diskio_old = diskiocounters
            except (IOError, UnboundLocalError):
                pass
        else:
            time_since_update = getTimeSinceLastUpdate('disk')
            diskio_new = diskiocounters
            for disk in diskio_new:
                if ((self.args is not None) and (not self.args.diskio_show_ramfs) and disk.startswith('ram')):
                    continue
                if self.is_hide(disk):
                    continue
                try:
                    read_count = (diskio_new[disk].read_count - self.diskio_old[disk].read_count)
                    write_count = (diskio_new[disk].write_count - self.diskio_old[disk].write_count)
                    read_bytes = (diskio_new[disk].read_bytes - self.diskio_old[disk].read_bytes)
                    write_bytes = (diskio_new[disk].write_bytes - self.diskio_old[disk].write_bytes)
                    diskstat = {'time_since_update': time_since_update, 'disk_name': disk, 'read_count': read_count, 'write_count': write_count, 'read_bytes': read_bytes, 'write_bytes': write_bytes}
                    if (self.has_alias(disk) is not None):
                        diskstat['alias'] = self.has_alias(disk)
                except KeyError:
                    continue
                else:
                    diskstat['key'] = self.get_key()
                    self.stats.append(diskstat)
            self.diskio_old = diskio_new
    elif (self.input_method == 'snmp'):
        pass
    return self.stats
