Code Duplication    Length = 21-23 lines in 2 locations

glances/plugins/containers/__init__.py 1 location

@@ 215-237 (lines=23) @@
212
            return False
213
        return all_tag[0].lower() == 'true'
214
215
    @GlancesPluginModel._check_decorator
216
    @GlancesPluginModel._log_result_decorator
217
    def update(self) -> List[Dict]:
218
        """Update Docker and podman stats using the input method."""
219
        # Connection should be ok
220
        if not self.watchers:
221
            return self.get_init_value()
222
223
        if self.input_method != 'local':
224
            return self.get_init_value()
225
226
        # Update stats
227
        stats = []
228
        for engine, watcher in iteritems(self.watchers):
229
            version, containers = watcher.update(all_tag=self._all_tag())
230
            for container in containers:
231
                container["engine"] = engine
232
            stats.extend(containers)
233
234
        # Sort and update the stats
235
        # @TODO: Have a look because sort did not work for the moment (need memory stats ?)
236
        self.sort_key, self.stats = sort_docker_stats(stats)
237
        return self.stats
238
239
    @staticmethod
240
    def memory_usage_no_cache(mem: Dict[str, float]) -> float:

glances/plugins/vms/__init__.py 1 location

@@ 152-172 (lines=21) @@
149
            return False
150
        return all_tag[0].lower() == 'true'
151
152
    @GlancesPluginModel._check_decorator
153
    @GlancesPluginModel._log_result_decorator
154
    def update(self) -> List[Dict]:
155
        """Update VMs stats using the input method."""
156
        # Connection should be ok
157
        if not self.watchers or self.input_method != 'local':
158
            return self.get_init_value()
159
160
        # Update stats
161
        stats = []
162
        for engine, watcher in iteritems(self.watchers):
163
            version, vms = watcher.update(all_tag=self._all_tag())
164
            for vm in vms:
165
                vm["engine"] = engine
166
                vm["engine_version"] = version
167
            stats.extend(vms)
168
169
        # Sort and update the stats
170
        # TODO: test
171
        self.sort_key, self.stats = sort_vm_stats(stats)
172
        return self.stats
173
174
    def update_views(self) -> bool:
175
        """Update stats views."""