def _get_time_list(cpu): """ Returns a 4 element list containing the amount of time the CPU has spent performing the different types of work 0 user 1 nice 2 system 3 idle Values are in USER_HZ or Jiffies """ if cpu.number == -1: cpu_times = gtop.cpu() else: cpu_times = gtop.cpu().cpus[cpu.number] return [cpu_times.user, cpu_times.nice, cpu_times.sys, cpu_times.idle]
def activate(self): self._net_icon = g15icontools.get_icon_path( ["network-transmit-receive", "gnome-fs-network", "network-server"], self.screen.height) self._cpu_icon = g15icontools.get_icon_path(CPU_ICONS, self.screen.height) self._mem_icon = g15icontools.get_icon_path( ["media-memory", "media-flash"], self.screen.height) self._thumb_icon = g15cairo.load_surface_from_file(self._cpu_icon) self.variant = 0 self.graphs = {} self.last_time_list = None self.last_times_list = [] self.last_time = 0 # CPU self.selected_cpu = None self.cpu_no = 0 self.cpu_data = [] selected_cpu_name = self.gconf_client.get_string(self.gconf_key + "/cpu") cpus = gtop.cpu().cpus for i in range(-1, len(cpus)): cpu = CPU(i) self.cpu_data.append(cpu) if cpu.name == selected_cpu_name: self.selected_cpu = cpu if self.selected_cpu is None: self.selected_cpu = self.cpu_data[0] # Net self.selected_net = None _, self.net_list = self._get_net_stats() net_name = self.gconf_client.get_string(self.gconf_key + "/net") self.net_data = [] for idx, n in enumerate(self.net_list): net = Net(idx, n) self.net_data.append(net) if net.name == net_name: self.selected_net = net if self.selected_net is None and len(self.net_data) > 0: self.selected_net = self.net_data[0] # Memory self.max_total_mem = 0 self.total = 1.0 self.cached = 0 self.free = 0 self.used = 0 self.cached_history = [0] * GRAPH_SIZE self.used_history = [0] * GRAPH_SIZE g15plugin.G15RefreshingPlugin.activate(self) self._set_panel() self.watch(["show_cpu_on_panel", "theme"], self._config_changed) self.screen.key_handler.action_listeners.append(self) # Start refreshing self.do_refresh()