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

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