# Buggy code
def update(self):
    """Update quicklook stats using the input method."""
    # Init new stats
    stats = self.get_init_value()

    # Grab quicklook stats: CPU, MEM and SWAP
    if self.input_method == "local":
        # Get the latest CPU percent value
        stats["cpu"] = cpu_percent.get()
        stats["percpu"] = cpu_percent.get(percpu=True)
        # Use the psutil lib for the memory (virtual and swap)
        stats["mem"] = psutil.virtual_memory().percent
        stats["swap"] = psutil.swap_memory().percent
    elif self.input_method == "snmp":
        # Not available
        pass

    # Optionnaly, get the CPU name/frequency
    # thanks to the cpuinfo lib: https://github.com/workhorsy/py-cpuinfo
    if cpuinfo_tag:
        cpu_info = cpuinfo.get_cpu_info()
        #  Check cpu_info (issue #881)
        if cpu_info is not None:
            # Use brand_raw if the key exist (issue #1685)
            if cpu_info.get("brand_raw") is not None:
                stats["cpu_name"] = cpu_info.get("brand_raw", "CPU")
            else:
                stats["cpu_name"] = cpu_info.get("brand", "CPU")
            if "hz_actual_raw" in cpu_info:
                stats["cpu_hz_current"] = cpu_info["hz_actual_raw"][0]
            elif "hz_actual" in cpu_info:
                stats["cpu_hz_current"] = cpu_info["hz_actual"][0]
            if "hz_advertised_raw" in cpu_info:
                stats["cpu_hz"] = cpu_info["hz_advertised_raw"][0]
            elif "hz_advertised" in cpu_info:
                stats["cpu_hz"] = cpu_info["hz_advertised"][0]

    # Update the stats
    self.stats = stats

    return self.stats


# Traceback (RuntimeError)
~$ glances
No swap devices configured
Traceback (most recent call last):
File "/usr/bin/glances", line 33, in <module>
sys.exit(load_entry_point('Glances==3.1.5', 'console_scripts', 'glances')())
File "/usr/lib/python3.7/site-packages/glances/__init__.py", line 143, in main
start(config=config, args=args)
File "/usr/lib/python3.7/site-packages/glances/__init__.py", line 108, in start
mode = GlancesMode(config=config, args=args)
File "/usr/lib/python3.7/site-packages/glances/standalone.py", line 78, in __init__
self.stats.update()
File "/usr/lib/python3.7/site-packages/glances/stats.py", line 234, in update
self._plugins[p].update()
File "/usr/lib/python3.7/site-packages/glances/plugins/glances_plugin.py", line 925, in wrapper
ret = fct(self, *args, **kw)
File "/usr/lib/python3.7/site-packages/glances/plugins/glances_plugin.py", line 935, in wrapper
ret = fct(*args, **kw)
File "/usr/lib/python3.7/site-packages/glances/plugins/glances_quicklook.py", line 84, in update
stats['swap'] = psutil.swap_memory().percent
File "/usr/lib/python3.7/site-packages/psutil/__init__.py", line 1980, in swap_memory
return _psplatform.swap_memory()
File "/usr/lib/python3.7/site-packages/psutil/_pssunos.py", line 150, in swap_memory
raise RuntimeError("'swap -l' failed (retcode=%s)" % p.returncode)
RuntimeError: 'swap -l' failed (retcode=1)

# Fixed code
def update(self):
    """Update quicklook stats using the input method."""
    # Init new stats
    stats = self.get_init_value()

    # Grab quicklook stats: CPU, MEM and SWAP
    if self.input_method == "local":
        # Get the latest CPU percent value
        stats["cpu"] = cpu_percent.get()
        stats["percpu"] = cpu_percent.get(percpu=True)
        # Use the psutil lib for the memory (virtual and swap)
        stats["mem"] = psutil.virtual_memory().percent
        try:
            stats["swap"] = psutil.swap_memory().percent
        except RuntimeError:
            # Correct issue in Illumos OS (see #1767)
            stats["swap"] = None
    elif self.input_method == "snmp":
        # Not available
        pass

    # Optionnaly, get the CPU name/frequency
    # thanks to the cpuinfo lib: https://github.com/workhorsy/py-cpuinfo
    if cpuinfo_tag:
        cpu_info = cpuinfo.get_cpu_info()
        #  Check cpu_info (issue #881)
        if cpu_info is not None:
            # Use brand_raw if the key exist (issue #1685)
            if cpu_info.get("brand_raw") is not None:
                stats["cpu_name"] = cpu_info.get("brand_raw", "CPU")
            else:
                stats["cpu_name"] = cpu_info.get("brand", "CPU")
            if "hz_actual_raw" in cpu_info:
                stats["cpu_hz_current"] = cpu_info["hz_actual_raw"][0]
            elif "hz_actual" in cpu_info:
                stats["cpu_hz_current"] = cpu_info["hz_actual"][0]
            if "hz_advertised_raw" in cpu_info:
                stats["cpu_hz"] = cpu_info["hz_advertised_raw"][0]
            elif "hz_advertised" in cpu_info:
                stats["cpu_hz"] = cpu_info["hz_advertised"][0]

    # Update the stats
    self.stats = stats

    return self.stats