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

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