Code Duplication    Length = 40-42 lines in 2 locations

glances/plugins/glances_batpercent.py 1 location

@@ 32-73 (lines=42) @@
29
    logger.debug("Batinfo library not found. Glances cannot grab battery info.")
30
31
32
class Plugin(GlancesPlugin):
33
34
    """Glances battery capacity plugin.
35
36
    stats is a list
37
    """
38
39
    def __init__(self, args=None):
40
        """Init the plugin."""
41
        super(Plugin, self).__init__(args=args)
42
43
        # Init the sensor class
44
        self.glancesgrabbat = GlancesGrabBat()
45
46
        # We do not want to display the stat in a dedicated area
47
        # The HDD temp is displayed within the sensors plugin
48
        self.display_curse = False
49
50
        # Init stats
51
        self.reset()
52
53
    def reset(self):
54
        """Reset/init the stats."""
55
        self.stats = []
56
57
    @GlancesPlugin._log_result_decorator
58
    def update(self):
59
        """Update battery capacity stats using the input method."""
60
        # Reset stats
61
        self.reset()
62
63
        if self.input_method == 'local':
64
            # Update stats
65
            self.glancesgrabbat.update()
66
            self.stats = self.glancesgrabbat.get()
67
68
        elif self.input_method == 'snmp':
69
            # Update stats using SNMP
70
            # Not avalaible
71
            pass
72
73
        return self.stats
74
75
76
class GlancesGrabBat(object):

glances/plugins/glances_hddtemp.py 1 location

@@ 31-70 (lines=40) @@
28
29
30
class Plugin(GlancesPlugin):
31
32
    """Glances HDD temperature sensors plugin.
33
34
    stats is a list
35
    """
36
37
    def __init__(self, args=None):
38
        """Init the plugin."""
39
        super(Plugin, self).__init__(args=args)
40
41
        # Init the sensor class
42
        self.glancesgrabhddtemp = GlancesGrabHDDTemp(args=args)
43
44
        # We do not want to display the stat in a dedicated area
45
        # The HDD temp is displayed within the sensors plugin
46
        self.display_curse = False
47
48
        # Init stats
49
        self.reset()
50
51
    def reset(self):
52
        """Reset/init the stats."""
53
        self.stats = []
54
55
    def update(self):
56
        """Update HDD stats using the input method."""
57
        # Reset stats
58
        self.reset()
59
60
        if self.input_method == 'local':
61
            # Update stats using the standard system lib
62
            self.stats = self.glancesgrabhddtemp.get()
63
64
        else:
65
            # Update stats using SNMP
66
            # Not available for the moment
67
            pass
68
69
        return self.stats
70
71
72
class GlancesGrabHDDTemp(object):
73