def add_package(self, pkg, is_removal=0): ch_icon = rcd_util.get_package_channel_icon(pkg, width=24, height=24) name = pkg.get("name", "???") if not is_removal: new_evr = rcd_util.get_package_EVR(pkg) old_evr = "-" if pkg.has_key("__old_package"): old_evr = rcd_util.get_package_EVR(pkg["__old_package"]) size = rcd_util.byte_size_to_string(pkg.get("file_size")) else: new_evr = "-" old_evr = rcd_util.get_package_EVR(pkg) size = rcd_util.byte_size_to_string(pkg.get("installed_size")) self.add_row(ch_icon, name, old_evr, new_evr, size)
def update_from_pendings(self, pending_list, show_size=1, show_rate=1): update_info = PendingView.update_from_pendings(self, pending_list, show_size, show_rate) (percent, elapsed_sec, remaining_sec, completed_size, total_size) = update_info if self.iconified and percent != -1: title = "%.1f%%" % percent if completed_size != -1 and total_size != -1: cs = rcd_util.byte_size_to_string(completed_size) ts = rcd_util.byte_size_to_string(total_size) title += " - %s / %s" % (cs, ts) title += " - " + self.window_title self.set_title(title)
def update(self, percent, elapsed_sec, remaining_sec, completed_size, total_size, show_size=1, show_rate=1): if percent <= 0: self.update_pulse() else: rate = 0 if elapsed_sec > 0: rate = completed_size / elapsed_sec self.progress_bar.set_fraction(percent / 100.0) msg = "%.1f%%" % percent if show_rate and rate > 0: rate_str = rcd_util.byte_size_to_string(rate) + "/s" else: rate_str = None if show_size and total_size > 0: cs = rcd_util.byte_size_to_string(completed_size) if total_size > 0: ts = rcd_util.byte_size_to_string(total_size) msg = msg + " - %s / %s" % (cs, ts) else: msg = msg + " - %s" % cs if rate_str: msg = msg + " (" + rate_str + ")" else: if rate_str: msg = msg + " - " + rate_str self.progress_bar.set_text(msg) # If our window has grown our shrunk, we want to make sure # that it stays centered. self.position_window()
def pkg_size(pkg): return rcd_util.byte_size_to_string(pkg.get("file_size"))
def pkg_size(pkg, pkg_info, key): size = pkg_info.get(key, "") if not size: size = 0 return rcd_util.byte_size_to_string(size)