# Buggy code
def msg_curse(self, args=None):
    """Return the dict to display in the curse interface."""
    # Init the return message
    ret = []

    # No per CPU stat ? Exit...
    if not self.stats:
        msg = "PER CPU not available"
        ret.append(self.curse_add_line(msg, "TITLE"))
        return ret

    # Build the string message
    # Header
    msg = "{:8}".format("PER CPU")
    ret.append(self.curse_add_line(msg, "TITLE"))

    # Total per-CPU usage
    for cpu in self.stats:
        msg = "{:>6}%".format(cpu["total"])
        ret.append(self.curse_add_line(msg))

    # Stats per-CPU
    for stat in ["user", "system", "idle", "iowait", "steal"]:
        if stat not in self.stats[0]:
            continue

        ret.append(self.curse_new_line())
        msg = "{:8}".format(stat + ":")
        ret.append(self.curse_add_line(msg))
        for cpu in self.stats:
            msg = "{:>6}%".format(cpu[stat])
            ret.append(self.curse_add_line(msg, self.get_alert(cpu[stat], header=stat)))

    # Return the message with decoration
    return ret


# Traceback (TypeError)
$  python -m glances -C ./dev/glances/conf/glances.conf --export-influxdb
Traceback (most recent call last):
File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/nicolargo/Dropbox/dev/glances/glances/__main__.py", line 29, in <module>
glances.main()
File "glances/__init__.py", line 225, in main
start_standalone(config=config, args=args)
File "glances/__init__.py", line 108, in start_standalone
standalone.serve_forever()
File "glances/standalone.py", line 117, in serve_forever
self.schedule.run()
File "/usr/lib64/python2.7/sched.py", line 117, in run
action(*argument)
File "glances/standalone.py", line 104, in __serve_forever
self.screen.update(self.stats)
File "glances/outputs/glances_curses.py", line 952, in update
self.flush(stats, cs_status=cs_status)
File "glances/outputs/glances_curses.py", line 930, in flush
self.display(stats, cs_status=cs_status)
File "glances/outputs/glances_curses.py", line 514, in display
__stat_display = self.__get_stat_display(stats, plugin_max_width)
File "glances/outputs/glances_curses.py", line 478, in __get_stat_display
ret[p] = stats.get_plugin(p).get_stats_display(args=self.args)
File "glances/plugins/glances_plugin.py", line 701, in get_stats_display
'msgdict': self.msg_curse(args),
File "/home/nicolargo/Dropbox/dev/glances/glances/plugins/glances_percpu.py", line 87, in msg_curse
msg = '{:>6}%'.format(cpu['total'])
TypeError: string indices must be integers

# Fixed code
def msg_curse(self, args=None):
    """Return the dict to display in the curse interface."""
    # Init the return message
    ret = []

    # No per CPU stat ? Exit...
    if not self.stats:
        msg = "PER CPU not available"
        ret.append(self.curse_add_line(msg, "TITLE"))
        return ret

    # Build the string message
    # Header
    msg = "{:8}".format("PER CPU")
    ret.append(self.curse_add_line(msg, "TITLE"))

    # Total per-CPU usage
    for cpu in self.stats:
        try:
            msg = "{:>6}%".format(cpu["total"])
        except TypeError:
            # TypeError: string indices must be integers (issue #1027)
            msg = "{:>6}%".format("?")
        ret.append(self.curse_add_line(msg))

    # Stats per-CPU
    for stat in ["user", "system", "idle", "iowait", "steal"]:
        if stat not in self.stats[0]:
            continue

        ret.append(self.curse_new_line())
        msg = "{:8}".format(stat + ":")
        ret.append(self.curse_add_line(msg))
        for cpu in self.stats:
            msg = "{:>6}%".format(cpu[stat])
            ret.append(self.curse_add_line(msg, self.get_alert(cpu[stat], header=stat)))

    # Return the message with decoration
    return ret