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

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