Code Duplication    Length = 5-7 lines in 6 locations

glances/plugins/glances_cpu.py 6 locations

@@ 324-330 (lines=7) @@
321
            msg = '{:>5}%'.format(self.stats['idle'])
322
            ret.append(self.curse_add_line(msg))
323
        # Steal CPU usage
324
        if 'steal' in self.stats:
325
            msg = '  {:8}'.format('steal:')
326
            ret.append(self.curse_add_line(msg, optional=self.get_views(key='steal', option='optional')))
327
            msg = '{:>5}%'.format(self.stats['steal'])
328
            ret.append(self.curse_add_line(
329
                msg, self.get_views(key='steal', option='decoration'),
330
                optional=self.get_views(key='steal', option='optional')))
331
        # syscalls
332
        # syscalls: number of system calls since boot. Always set to 0 on Linux. (do not display)
333
        if 'syscalls' in self.stats and not LINUX:
@@ 301-307 (lines=7) @@
298
            msg = '{:>6}'.format(self.stats['nb_log_core'])
299
            ret.append(self.curse_add_line(msg))
300
        # IOWait CPU
301
        if 'iowait' in self.stats:
302
            msg = '  {:8}'.format('iowait:')
303
            ret.append(self.curse_add_line(msg, optional=self.get_views(key='iowait', option='optional')))
304
            msg = '{:>5}%'.format(self.stats['iowait'])
305
            ret.append(self.curse_add_line(
306
                msg, self.get_views(key='iowait', option='decoration'),
307
                optional=self.get_views(key='iowait', option='optional')))
308
        # soft_interrupts
309
        if 'soft_interrupts' in self.stats:
310
            msg = '  {:8}'.format('sw_int:')
@@ 251-257 (lines=7) @@
248
            msg = '{:>5}%'.format(self.stats['nice'])
249
            ret.append(self.curse_add_line(msg, optional=self.get_views(key='nice', option='optional')))
250
        # ctx_switches
251
        if 'ctx_switches' in self.stats:
252
            msg = '  {:8}'.format('ctx_sw:')
253
            ret.append(self.curse_add_line(msg, optional=self.get_views(key='ctx_switches', option='optional')))
254
            msg = '{:>5}'.format(int(self.stats['ctx_switches'] // self.stats['time_since_update']))
255
            ret.append(self.curse_add_line(
256
                msg, self.get_views(key='ctx_switches', option='decoration'),
257
                optional=self.get_views(key='ctx_switches', option='optional')))
258
259
        # New line
260
        ret.append(self.curse_new_line())
@@ 333-337 (lines=5) @@
330
                optional=self.get_views(key='steal', option='optional')))
331
        # syscalls
332
        # syscalls: number of system calls since boot. Always set to 0 on Linux. (do not display)
333
        if 'syscalls' in self.stats and not LINUX:
334
            msg = '  {:8}'.format('syscal:')
335
            ret.append(self.curse_add_line(msg, optional=self.get_views(key='syscalls', option='optional')))
336
            msg = '{:>5}'.format(int(self.stats['syscalls'] // self.stats['time_since_update']))
337
            ret.append(self.curse_add_line(msg, optional=self.get_views(key='syscalls', option='optional')))
338
339
        # Return the message with decoration
340
        return ret
@@ 309-313 (lines=5) @@
306
                msg, self.get_views(key='iowait', option='decoration'),
307
                optional=self.get_views(key='iowait', option='optional')))
308
        # soft_interrupts
309
        if 'soft_interrupts' in self.stats:
310
            msg = '  {:8}'.format('sw_int:')
311
            ret.append(self.curse_add_line(msg, optional=self.get_views(key='soft_interrupts', option='optional')))
312
            msg = '{:>5}'.format(int(self.stats['soft_interrupts'] // self.stats['time_since_update']))
313
            ret.append(self.curse_add_line(msg, optional=self.get_views(key='soft_interrupts', option='optional')))
314
315
        # New line
316
        ret.append(self.curse_new_line())
@@ 280-284 (lines=5) @@
277
            msg = '{:>5}%'.format(self.stats['irq'])
278
            ret.append(self.curse_add_line(msg, optional=self.get_views(key='irq', option='optional')))
279
        # interrupts
280
        if 'interrupts' in self.stats:
281
            msg = '  {:8}'.format('inter:')
282
            ret.append(self.curse_add_line(msg, optional=self.get_views(key='interrupts', option='optional')))
283
            msg = '{:>5}'.format(int(self.stats['interrupts'] // self.stats['time_since_update']))
284
            ret.append(self.curse_add_line(msg, optional=self.get_views(key='interrupts', option='optional')))
285
286
        # New line
287
        ret.append(self.curse_new_line())