Code Duplication    Length = 10-14 lines in 3 locations

glances/plugins/glances_sensors.py 1 location

@@ 156-169 (lines=14) @@
153
154
    def update_views(self):
155
        """Update stats views."""
156
        # Call the father's method
157
        super(Plugin, self).update_views()
158
159
        # Add specifics informations
160
        # Alert
161
        for i in self.stats:
162
            if not i['value']:
163
                continue
164
            if i['type'] == 'battery':
165
                self.views[i[self.get_key()]]['value']['decoration'] = self.get_alert(100 - i['value'], header=i['type'])
166
            else:
167
                self.views[i[self.get_key()]]['value']['decoration'] = self.get_alert(i['value'], header=i['type'])
168
169
    def msg_curse(self, args=None):
170
        """Return the dict to display in the curse interface."""
171
        # Init the return message
172
        ret = []

glances/plugins/glances_diskio.py 1 location

@@ 143-155 (lines=13) @@
140
        elif self.input_method == 'snmp':
141
            # Update stats using SNMP
142
            # No standard way for the moment...
143
            pass
144
145
        return self.stats
146
147
    def update_views(self):
148
        """Update stats views."""
149
        # Call the father's method
150
        super(Plugin, self).update_views()
151
152
        # Add specifics informations
153
        # Alert
154
        for i in self.stats:
155
            disk_real_name = i['disk_name']
156
            self.views[i[self.get_key()]]['read_bytes']['decoration'] = self.get_alert(int(i['read_bytes'] // i['time_since_update']),
157
                                                                                       header=disk_real_name + '_rx')
158
            self.views[i[self.get_key()]]['write_bytes']['decoration'] = self.get_alert(int(i['write_bytes'] // i['time_since_update']),

glances/plugins/glances_wifi.py 1 location

@@ 147-156 (lines=10) @@
144
145
        return ret
146
147
    def update_views(self):
148
        """Update stats views."""
149
        # Call the father's method
150
        super(Plugin, self).update_views()
151
152
        # Add specifics informations
153
        # Alert on signal thresholds
154
        for i in self.stats:
155
            self.views[i[self.get_key()]]['signal']['decoration'] = self.get_alert(i['signal'])
156
            self.views[i[self.get_key()]]['quality']['decoration'] = self.views[i[self.get_key()]]['signal']['decoration']
157
158
    def msg_curse(self, args=None, max_width=None):
159
        """Return the dict to display in the curse interface."""