Code Duplication    Length = 63-63 lines in 2 locations

glances/plugins/programlist/__init__.py 1 location

@@ 170-232 (lines=63) @@
167
        msg = self.layout_stat['nprocs'].format(p['nprocs'])
168
        return self.curse_add_line(msg)
169
170
    def _msg_curse_header(self, ret, process_sort_key, args=None):
171
        """Build the header and add it to the ret dict."""
172
        sort_style = 'SORT'
173
174
        display_stats = [i for i in self.enable_stats if i not in glances_processes.disable_stats]
175
176
        if 'cpu_percent' in display_stats:
177
            if args.disable_irix and 0 < self.nb_log_core < 10:
178
                msg = self.layout_header['cpu'].format('CPU%/' + str(self.nb_log_core))
179
            elif args.disable_irix and self.nb_log_core != 0:
180
                msg = self.layout_header['cpu'].format('CPU%/C')
181
            else:
182
                msg = self.layout_header['cpu'].format('CPU%')
183
            ret.append(self.curse_add_line(msg, sort_style if process_sort_key == 'cpu_percent' else 'DEFAULT'))
184
185
        if 'memory_percent' in display_stats:
186
            msg = self.layout_header['mem'].format('MEM%')
187
            ret.append(self.curse_add_line(msg, sort_style if process_sort_key == 'memory_percent' else 'DEFAULT'))
188
        if 'memory_info' in display_stats:
189
            msg = self.layout_header['virt'].format('VIRT')
190
            ret.append(self.curse_add_line(msg, optional=True))
191
            msg = self.layout_header['res'].format('RES')
192
            ret.append(self.curse_add_line(msg, optional=True))
193
        if 'nprocs' in display_stats:
194
            msg = self.layout_header['nprocs'].format('NPROCS')
195
            ret.append(self.curse_add_line(msg))
196
        if 'username' in display_stats:
197
            msg = self.layout_header['user'].format('USER')
198
            ret.append(self.curse_add_line(msg, sort_style if process_sort_key == 'username' else 'DEFAULT'))
199
        if 'cpu_times' in display_stats:
200
            msg = self.layout_header['time'].format('TIME+')
201
            ret.append(
202
                self.curse_add_line(msg, sort_style if process_sort_key == 'cpu_times' else 'DEFAULT', optional=True)
203
            )
204
        if 'num_threads' in display_stats:
205
            msg = self.layout_header['thread'].format('THR')
206
            ret.append(self.curse_add_line(msg))
207
        if 'nice' in display_stats:
208
            msg = self.layout_header['nice'].format('NI')
209
            ret.append(self.curse_add_line(msg))
210
        if 'status' in display_stats:
211
            msg = self.layout_header['status'].format('S')
212
            ret.append(self.curse_add_line(msg))
213
        if 'io_counters' in display_stats:
214
            msg = self.layout_header['ior'].format('R/s')
215
            ret.append(
216
                self.curse_add_line(
217
                    msg, sort_style if process_sort_key == 'io_counters' else 'DEFAULT', optional=True, additional=True
218
                )
219
            )
220
            msg = self.layout_header['iow'].format('W/s')
221
            ret.append(
222
                self.curse_add_line(
223
                    msg, sort_style if process_sort_key == 'io_counters' else 'DEFAULT', optional=True, additional=True
224
                )
225
            )
226
        if args.is_standalone and not args.disable_cursor:
227
            shortkey = "('k' to kill)"
228
        else:
229
            shortkey = ""
230
        if 'cmdline' in display_stats:
231
            msg = self.layout_header['command'].format("Programs", shortkey)
232
            ret.append(self.curse_add_line(msg, sort_style if process_sort_key == 'name' else 'DEFAULT'))
233
234
    def _msg_curse_sum(self, ret, sep_char='_', mmm=None, args=None):
235
        """

glances/plugins/processlist/__init__.py 1 location

@@ 702-764 (lines=63) @@
699
700
        functools.reduce(lambda ret, step: step(ret, prog), steps, ret)
701
702
    def _msg_curse_header(self, ret, process_sort_key, args=None):
703
        """Build the header and add it to the ret dict."""
704
        sort_style = 'SORT'
705
706
        display_stats = [i for i in self.enable_stats if i not in glances_processes.disable_stats]
707
708
        if 'cpu_percent' in display_stats:
709
            if args.disable_irix and 0 < self.nb_log_core < 10:
710
                msg = self.layout_header['cpu'].format('CPU%/' + str(self.nb_log_core))
711
            elif args.disable_irix and self.nb_log_core != 0:
712
                msg = self.layout_header['cpu'].format('CPU%/C')
713
            else:
714
                msg = self.layout_header['cpu'].format('CPU%')
715
            ret.append(self.curse_add_line(msg, sort_style if process_sort_key == 'cpu_percent' else 'DEFAULT'))
716
717
        if 'memory_percent' in display_stats:
718
            msg = self.layout_header['mem'].format('MEM%')
719
            ret.append(self.curse_add_line(msg, sort_style if process_sort_key == 'memory_percent' else 'DEFAULT'))
720
        if 'memory_info' in display_stats:
721
            msg = self.layout_header['virt'].format('VIRT')
722
            ret.append(self.curse_add_line(msg, optional=True))
723
            msg = self.layout_header['res'].format('RES')
724
            ret.append(self.curse_add_line(msg, optional=True))
725
        if 'pid' in display_stats:
726
            msg = self.layout_header['pid'].format('PID', width=self._max_pid_size())
727
            ret.append(self.curse_add_line(msg))
728
        if 'username' in display_stats:
729
            msg = self.layout_header['user'].format('USER')
730
            ret.append(self.curse_add_line(msg, sort_style if process_sort_key == 'username' else 'DEFAULT'))
731
        if 'cpu_times' in display_stats:
732
            msg = self.layout_header['time'].format('TIME+')
733
            ret.append(
734
                self.curse_add_line(msg, sort_style if process_sort_key == 'cpu_times' else 'DEFAULT', optional=True)
735
            )
736
        if 'num_threads' in display_stats:
737
            msg = self.layout_header['thread'].format('THR')
738
            ret.append(self.curse_add_line(msg))
739
        if 'nice' in display_stats:
740
            msg = self.layout_header['nice'].format('NI')
741
            ret.append(self.curse_add_line(msg))
742
        if 'status' in display_stats:
743
            msg = self.layout_header['status'].format('S')
744
            ret.append(self.curse_add_line(msg))
745
        if 'io_counters' in display_stats:
746
            msg = self.layout_header['ior'].format('R/s')
747
            ret.append(
748
                self.curse_add_line(
749
                    msg, sort_style if process_sort_key == 'io_counters' else 'DEFAULT', optional=True, additional=True
750
                )
751
            )
752
            msg = self.layout_header['iow'].format('W/s')
753
            ret.append(
754
                self.curse_add_line(
755
                    msg, sort_style if process_sort_key == 'io_counters' else 'DEFAULT', optional=True, additional=True
756
                )
757
            )
758
        if args.is_standalone and not args.disable_cursor:
759
            shortkey = "('e' to pin | 'k' to kill)"
760
        else:
761
            shortkey = ""
762
        if 'cmdline' in display_stats:
763
            msg = self.layout_header['command'].format("Command", shortkey)
764
            ret.append(self.curse_add_line(msg, sort_style if process_sort_key == 'name' else 'DEFAULT'))
765
766
    def _msg_curse_sum(self, ret, sep_char='_', mmm=None, args=None):
767
        """