def set_details_list(pkg, style): details_list.clear() if style == 'sync': details_list.append([_('Repository')+':', pkg.db.name]) if pkg.groups: details_list.append([_('Groups')+':', ' '.join(pkg.groups)]) if style == 'sync': details_list.append([_('Compressed Size')+':', common.format_size(pkg.size)]) details_list.append([_('Download Size')+':', common.format_size(pkg.download_size)]) if style == 'local': details_list.append([_('Installed Size')+':', common.format_size(pkg.isize)]) details_list.append([_('Packager')+':', pkg.packager]) details_list.append([_('Architecture')+':', pkg.arch]) #details_list.append([_('Build Date')+':', strftime("%a %d %b %Y %X %Z", localtime(pkg.builddate))]) if style == 'local': details_list.append([_('Install Date')+':', strftime("%a %d %b %Y %X %Z", localtime(pkg.installdate))]) if pkg.reason == pyalpm.PKG_REASON_EXPLICIT: reason = _('Explicitly installed') elif pkg.reason == pyalpm.PKG_REASON_DEPEND: reason = _('Installed as a dependency for another package') else: reason = _('Unknown') details_list.append([_('Install Reason')+':', reason]) if style == 'sync': #details_list.append([_('Install Script')':', 'Yes' if pkg.has_scriptlet else 'No']) #details_list.append(['MD5 Sum:', pkg.md5sum]) #details_list.append(['SHA256 Sum:', pkg.sha256sum]) details_list.append([_('Signatures')+':', 'Yes' if pkg.base64_sig else 'No']) if style == 'local': if len(pkg.backup) != 0: #details_list.append(['_(Backup files)+':', '\n'.join(["%s %s" % (md5, file) for (file, md5) in pkg.backup])]) details_list.append([_('Backup files')+':', '\n'.join(["%s" % (file) for (file, md5) in pkg.backup])])
def have_updates(): while Gtk.events_pending(): Gtk.main_iteration() UpdaterWindow.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH)) while Gtk.events_pending(): Gtk.main_iteration() update_listore.clear() update_top_label.set_justify(Gtk.Justification.CENTER) updates = transaction.available_updates[1] if not updates: update_bottom_label.set_markup('') update_top_label.set_markup('<big><b>{}</b></big>'.format(_('Your system is up-to-date'))) UpdaterApplyButton.set_sensitive(False) else: UpdaterApplyButton.set_sensitive(True) dsize = 0 for name, version, db, tarpath, size in updates: dsize += size if size: size_str = common.format_size(size) else: size_str = '' update_listore.append([name+' '+version, size_str]) if dsize == 0: update_bottom_label.set_markup('') else: update_bottom_label.set_markup('<b>{} {}</b>'.format(_('Total download size:'), common.format_size(dsize))) if len(updates) == 1: update_top_label.set_markup('<big><b>{}</b></big>'.format(_('1 available update'))) else: update_top_label.set_markup('<big><b>{}</b></big>'.format(_('{number} available updates').format(number = len(updates)))) UpdaterWindow.get_window().set_cursor(None)
def set_desc(pkg, style): """ Args : pkg_object -- the package to display style -- 'local' or 'sync' """ if style not in ["local", "sync", "file"]: raise ValueError("Invalid style for package info formatting") package_desc.clear() if style == "sync": package_desc.append(["Repository:", pkg.db.name]) package_desc.append(["Name:", pkg.name]) package_desc.append(["Version:", pkg.version]) package_desc.append(["Description:", pkg.desc]) package_desc.append(["URL:", pkg.url]) package_desc.append(["Licenses:", " ".join(pkg.licenses)]) package_desc.append(["Groups:", " ".join(pkg.groups)]) package_desc.append(["Provides:", " ".join(pkg.provides)]) package_desc.append(["Depends On:", " ".join(pkg.depends)]) package_desc.append(["Optional Deps:", "\n".join(pkg.optdepends)]) if style == "local": package_desc.append(["Required By:", " ".join(pkg.compute_requiredby())]) package_desc.append(["Conflicts With:", " ".join(pkg.conflicts)]) package_desc.append(["Replaces:", " ".join(pkg.replaces)]) if style == "sync": package_desc.append(["Download Size:", common.format_size(pkg.size)]) if style == "file": package_desc.append(["Compressed Size:", common.format_size(pkg.size)]) package_desc.append(["Installed Size:", common.format_size(pkg.isize)]) package_desc.append(["Packager:", pkg.packager]) package_desc.append(["Architecture:", pkg.arch]) package_desc.append(["Build Date:", strftime("%a %d %b %Y %X %Z", localtime(pkg.builddate))]) if style == "local": package_desc.append(["Install Date:", strftime("%a %d %b %Y %X %Z", localtime(pkg.installdate))]) if pkg.reason == pyalpm.PKG_REASON_EXPLICIT: reason = "Explicitly installed" elif pkg.reason == pyalpm.PKG_REASON_DEPEND: reason = "Installed as a dependency for another package" else: reason = "N/A" package_desc.append(["Install Reason:", reason]) if style != "sync": package_desc.append(["Install Script:", "Yes" if pkg.has_scriptlet else "No"]) if style == "sync": package_desc.append(["MD5 Sum:", pkg.md5sum]) package_desc.append(["SHA256 Sum:", pkg.sha256sum]) package_desc.append(["Signatures:", "Yes" if pkg.base64_sig else "No"]) if style == "local": if len(pkg.backup) == 0: package_desc.append(["Backup files:", ""]) else: package_desc.append(["Backup files:", "\n".join(["%s %s" % (md5, file) for (file, md5) in pkg.backup])])
def cb_dl(self, _target, _transferred, _total): if _target.endswith('.db'): action = _('Refreshing {repo}').format(repo = _target.replace('.db', ''))+'...' action_long = '' icon = 'pamac-refresh' else: action = _('Downloading {pkgname}').format(pkgname = _target.replace('.pkg.tar.xz', ''))+'...' action_long = action+'\n' icon = 'pamac-download' if self.total_size > 0: percent = round((_transferred+self.already_transferred)/self.total_size, 2) if _transferred+self.already_transferred <= self.total_size: target = '{transferred}/{size}'.format(transferred = common.format_size(_transferred+self.already_transferred), size = common.format_size(self.total_size)) else: target = '' else: percent = round(_transferred/_total, 2) target = '' if action != self.previous_action: self.previous_action = action self.EmitAction(action) if action_long != self.previous_action_long: self.previous_action_long = action_long self.EmitActionLong(action_long) if icon != self.previous_icon: self.previous_icon = icon self.EmitIcon(icon) if target != self.previous_target: self.previous_target = target self.EmitTarget(target) if percent != self.previous_percent: self.previous_percent = percent self.EmitPercent(percent) elif _transferred == _total: self.already_transferred += _total
def cb_dl(self, _target, _transferred, total): if self.total_size > 0: fraction = (_transferred + self.already_transferred) / self.total_size size = 0 if t.to_remove or t.to_add: for pkg in t.to_remove + t.to_add: if pkg.name + "-" + pkg.version in _target: size = pkg.size if _transferred == size: self.already_transferred += size self.action = "Downloading " + common.format_size(self.total_size) self.target = _target if fraction > 1: self.percent = 0 else: self.percent = fraction self.icon = "/usr/share/pamac/icons/24x24/status/package-download.png" else: self.action = "Refreshing..." self.target = _target self.percent = 0 self.icon = "/usr/share/pamac/icons/24x24/status/refresh-cache.png" self.EmitAction(self.action) self.EmitIcon(self.icon) self.EmitTarget(self.target) self.EmitPercent(str(self.percent))
def size_column_display_func(column, cell, treemodel, treeiter, data): if treemodel[treeiter][0] == _('No package found'): cell.set_property("text", '') elif treemodel[treeiter][0].isize: cell.set_property("text", common.format_size(treemodel[treeiter][0].isize)) else: cell.set_property("text", '')
def set_details_list(pkg, style): details_list.clear() if style == 'sync': details_list.append([_('Repository') + ':', pkg.db.name]) if pkg.groups: details_list.append([_('Groups') + ':', ' '.join(pkg.groups)]) if style == 'sync': details_list.append( [_('Compressed Size') + ':', common.format_size(pkg.size)]) details_list.append( [_('Download Size') + ':', common.format_size(pkg.download_size)]) if style == 'local': details_list.append( [_('Installed Size') + ':', common.format_size(pkg.isize)]) details_list.append([_('Packager') + ':', pkg.packager]) details_list.append([_('Architecture') + ':', pkg.arch]) #details_list.append([_('Build Date')+':', strftime("%a %d %b %Y %X %Z", localtime(pkg.builddate))]) if style == 'local': details_list.append([ _('Install Date') + ':', strftime("%a %d %b %Y %X %Z", localtime(pkg.installdate)) ]) if pkg.reason == pyalpm.PKG_REASON_EXPLICIT: reason = _('Explicitly installed') elif pkg.reason == pyalpm.PKG_REASON_DEPEND: reason = _('Installed as a dependency for another package') else: reason = _('Unknown') details_list.append([_('Install Reason') + ':', reason]) if style == 'sync': #details_list.append([_('Install Script')':', 'Yes' if pkg.has_scriptlet else 'No']) #details_list.append(['MD5 Sum:', pkg.md5sum]) #details_list.append(['SHA256 Sum:', pkg.sha256sum]) details_list.append( [_('Signatures') + ':', 'Yes' if pkg.base64_sig else 'No']) if style == 'local': if len(pkg.backup) != 0: #details_list.append(['_(Backup files)+':', '\n'.join(["%s %s" % (md5, file) for (file, md5) in pkg.backup])]) details_list.append([ _('Backup files') + ':', '\n'.join(["%s" % (file) for (file, md5) in pkg.backup]) ])
def set_transaction_sum(show_updates=True): dsize = 0 transaction_sum.clear() transaction_dict = get_transaction_sum() sum_top_label.set_markup("<big><b>{}</b></big>".format(_("Transaction Summary"))) if transaction_dict["to_remove"]: transaction_sum.append([_("To remove") + ":", transaction_dict["to_remove"][0]]) i = 1 while i < len(transaction_dict["to_remove"]): transaction_sum.append(["", transaction_dict["to_remove"][i]]) i += 1 if transaction_dict["to_downgrade"]: transaction_sum.append([_("To downgrade") + ":", transaction_dict["to_downgrade"][0][0]]) dsize += transaction_dict["to_downgrade"][0][1] i = 1 while i < len(transaction_dict["to_downgrade"]): transaction_sum.append(["", transaction_dict["to_downgrade"][i][0]]) dsize += transaction_dict["to_downgrade"][i][1] i += 1 if transaction_dict["to_build"]: transaction_sum.append([_("To build") + ":", transaction_dict["to_build"][0]]) i = 1 while i < len(transaction_dict["to_build"]): transaction_sum.append(["", transaction_dict["to_build"][i]]) i += 1 if transaction_dict["to_install"]: transaction_sum.append([_("To install") + ":", transaction_dict["to_install"][0][0]]) dsize += transaction_dict["to_install"][0][1] i = 1 while i < len(transaction_dict["to_install"]): transaction_sum.append(["", transaction_dict["to_install"][i][0]]) dsize += transaction_dict["to_install"][i][1] i += 1 if transaction_dict["to_reinstall"]: transaction_sum.append([_("To reinstall") + ":", transaction_dict["to_reinstall"][0][0]]) dsize += transaction_dict["to_reinstall"][0][1] i = 1 while i < len(transaction_dict["to_reinstall"]): transaction_sum.append(["", transaction_dict["to_reinstall"][i][0]]) dsize += transaction_dict["to_reinstall"][i][1] i += 1 if show_updates: if transaction_dict["to_update"]: transaction_sum.append([_("To update") + ":", transaction_dict["to_update"][0][0]]) dsize += transaction_dict["to_update"][0][1] i = 1 while i < len(transaction_dict["to_update"]): transaction_sum.append(["", transaction_dict["to_update"][i][0]]) dsize += transaction_dict["to_update"][i][1] i += 1 else: for name, size in transaction_dict["to_update"]: dsize += size if dsize == 0: sum_bottom_label.set_markup("") else: sum_bottom_label.set_markup("<b>{} {}</b>".format(_("Total download size:"), common.format_size(dsize)))
def cb_dl(self, _target, _transferred, _total): if _target.endswith('.db'): action = _('Refreshing {repo}').format( repo=_target.replace('.db', '')) + '...' action_long = '' icon = 'pamac-refresh' else: action = _('Downloading {pkgname}').format( pkgname=_target.replace('.pkg.tar.xz', '')) + '...' action_long = action + '\n' icon = 'pamac-download' if self.total_size > 0: percent = round( (_transferred + self.already_transferred) / self.total_size, 2) if _transferred + self.already_transferred <= self.total_size: target = '{transferred}/{size}'.format( transferred=common.format_size(_transferred + self.already_transferred), size=common.format_size(self.total_size)) else: target = '' else: percent = round(_transferred / _total, 2) target = '' if action != self.previous_action: self.previous_action = action self.EmitAction(action) if action_long != self.previous_action_long: self.previous_action_long = action_long self.EmitActionLong(action_long) if icon != self.previous_icon: self.previous_icon = icon self.EmitIcon(icon) if target != self.previous_target: self.previous_target = target self.EmitTarget(target) if percent != self.previous_percent: self.previous_percent = percent self.EmitPercent(percent) elif _transferred == _total: self.already_transferred += _total
def write_file(chunk): nonlocal transferred nonlocal f if cancel_download: if ftp: ftp.quit() raise Exception("Download cancelled") return f.write(chunk) transferred += len(chunk) if total_size > 0: percent = round(transferred / total_size, 2) percent_handler(percent) if transferred <= total_size: target = "{transferred}/{size}".format( transferred=common.format_size(transferred), size=common.format_size(total_size) ) else: target = "" target_handler(target) while Gtk.events_pending(): Gtk.main_iteration()
def write_file(chunk): nonlocal transferred nonlocal f if cancel_download: if ftp: ftp.quit() raise Exception('Download cancelled') return f.write(chunk) transferred += len(chunk) if total_size > 0: percent = round(transferred / total_size, 2) percent_handler(percent) if transferred <= total_size: target = '{transferred}/{size}'.format( transferred=common.format_size(transferred), size=common.format_size(total_size)) else: target = '' target_handler(target) while Gtk.events_pending(): Gtk.main_iteration()
def have_updates(): do_syncfirst, updates = transaction.get_updates() update_listore.clear() update_label.set_justify(Gtk.Justification.CENTER) if not updates: update_listore.append(["", ""]) update_label.set_markup("<big><b>No update available</b></big>") return False else: for pkg in updates: pkgname = pkg.name + " " + pkg.version update_listore.append([pkgname, common.format_size(pkg.size)]) update_label.set_markup("<big><b>Available updates</b></big>") return True
def have_updates(): while Gtk.events_pending(): Gtk.main_iteration() UpdaterWindow.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH)) while Gtk.events_pending(): Gtk.main_iteration() update_listore.clear() update_top_label.set_justify(Gtk.Justification.CENTER) updates = transaction.available_updates[1] if not updates: update_bottom_label.set_markup('') update_top_label.set_markup('<big><b>{}</b></big>'.format( _('Your system is up-to-date'))) UpdaterApplyButton.set_sensitive(False) else: UpdaterApplyButton.set_sensitive(True) dsize = 0 for name, version, db, tarpath, size in updates: dsize += size if size: size_str = common.format_size(size) else: size_str = '' update_listore.append([name + ' ' + version, size_str]) if dsize == 0: update_bottom_label.set_markup('') else: update_bottom_label.set_markup('<b>{} {}</b>'.format( _('Total download size:'), common.format_size(dsize))) if len(updates) == 1: update_top_label.set_markup('<big><b>{}</b></big>'.format( _('1 available update'))) else: update_top_label.set_markup('<big><b>{}</b></big>'.format( _('{number} available updates').format(number=len(updates)))) UpdaterWindow.get_window().set_cursor(None)
def set_transaction_sum(show_updates=True): dsize = 0 transaction_sum.clear() transaction_dict = get_transaction_sum() sum_top_label.set_markup('<big><b>{}</b></big>'.format( _('Transaction Summary'))) if transaction_dict['to_remove']: transaction_sum.append( [_('To remove') + ':', transaction_dict['to_remove'][0]]) i = 1 while i < len(transaction_dict['to_remove']): transaction_sum.append(['', transaction_dict['to_remove'][i]]) i += 1 if transaction_dict['to_downgrade']: transaction_sum.append( [_('To downgrade') + ':', transaction_dict['to_downgrade'][0][0]]) dsize += transaction_dict['to_downgrade'][0][1] i = 1 while i < len(transaction_dict['to_downgrade']): transaction_sum.append( ['', transaction_dict['to_downgrade'][i][0]]) dsize += transaction_dict['to_downgrade'][i][1] i += 1 if transaction_dict['to_build']: transaction_sum.append( [_('To build') + ':', transaction_dict['to_build'][0]]) i = 1 while i < len(transaction_dict['to_build']): transaction_sum.append(['', transaction_dict['to_build'][i]]) i += 1 if transaction_dict['to_install']: transaction_sum.append( [_('To install') + ':', transaction_dict['to_install'][0][0]]) dsize += transaction_dict['to_install'][0][1] i = 1 while i < len(transaction_dict['to_install']): transaction_sum.append(['', transaction_dict['to_install'][i][0]]) dsize += transaction_dict['to_install'][i][1] i += 1 if transaction_dict['to_reinstall']: transaction_sum.append( [_('To reinstall') + ':', transaction_dict['to_reinstall'][0][0]]) dsize += transaction_dict['to_reinstall'][0][1] i = 1 while i < len(transaction_dict['to_reinstall']): transaction_sum.append( ['', transaction_dict['to_reinstall'][i][0]]) dsize += transaction_dict['to_reinstall'][i][1] i += 1 if show_updates: if transaction_dict['to_update']: transaction_sum.append( [_('To update') + ':', transaction_dict['to_update'][0][0]]) dsize += transaction_dict['to_update'][0][1] i = 1 while i < len(transaction_dict['to_update']): transaction_sum.append( ['', transaction_dict['to_update'][i][0]]) dsize += transaction_dict['to_update'][i][1] i += 1 else: for name, size in transaction_dict['to_update']: dsize += size if dsize == 0: sum_bottom_label.set_markup('') else: sum_bottom_label.set_markup('<b>{} {}</b>'.format( _('Total download size:'), common.format_size(dsize)))