def backend_signal_receiver(self, messages): for message in messages: (signal_type, action_content) = message if signal_type == "download-start": (pkg_name, action_type) = action_content if action_type == ACTION_INSTALL: pass elif action_type == ACTION_UPGRADE: pass self.label.set_label("开始下载...") elif signal_type == "download-update": (pkg_name, action_type, percent, speed, finish_number, total, downloaded_size, total_size) = action_content if action_type == ACTION_INSTALL: pass elif action_type == ACTION_UPGRADE: pass self.label.set_label("正在下载:%i%% \n已完成:%s/%s (%s/%s)" % ( percent, utils.bit_to_human_str(downloaded_size), utils.bit_to_human_str(total_size), finish_number+1, total, )) elif signal_type == "download-finish": (pkg_name, action_type) = action_content if action_type == ACTION_INSTALL: pass elif action_type == ACTION_UPGRADE: pass self.label.set_label("下载完成") elif signal_type == "download-failed": (pkg_name, action_type, error) = action_content self.label.set_label("下载失败,2秒钟后退出...") gtk.timeout_add(2000, gtk.main_quit) elif signal_type == "action-start": (pkg_name, action_type) = action_content self.label.set_label("开始%s" % ACTION_STR[action_type]) elif signal_type == "action-update": (pkg_name, action_type, percent, status) = action_content if int(float(percent)) != 100: self.label.set_label("正在%s - %i%%" % (ACTION_STR[action_type], percent)) else: self.label.set_label("%s完成,2秒钟后退出" % ACTION_STR[action_type]) gtk.timeout_add(2000, gtk.main_quit) elif signal_type == "action-finish": (pkg_name, action_type, pkg_info_list) = action_content self.label.set_label("%s完成,2秒钟后退出" % ACTION_STR[action_type]) gtk.timeout_add(2000, gtk.main_quit) elif signal_type == "action-failed": (pkg_name, action_type, pkg_info_list, errormsg) = action_content self.label.set_label("%s失败,2秒钟后退出" % ACTION_STR[action_type]) gtk.timeout_add(2000, gtk.main_quit)
def handle_pkg_download_size(self, reply): # FIXME: download information display if reply[0] == PKG_SIZE_OWN or reply[0] == PKG_SIZE_DOWNLOAD: self.left_size_label.set_text(_("Size: %s") % bit_to_human_str(reply[1])) elif reply[0] == PKG_SIZE_ERROR: self.left_size_label.set_text("") global_logger.logerror("Error for calculate pkg size!")
def handle_pkg_download_size(self, reply, success): # FIXME: download information display if success: if reply[0] == PKG_SIZE_OWN or reply[0] == PKG_SIZE_DOWNLOAD: self.left_size_label.set_text(_("Size: %s") % bit_to_human_str(reply[1])) elif reply[0] == PKG_SIZE_ERROR: self.left_size_label.set_text("") global_logger.logerror("Error for calculate pkg size!") else: global_logger.logerror("request_pkgs_install_status handle_dbus_error") global_logger.logerror(reply)
def handle_pkg_download_size(self, reply, success): # FIXME: download information display if success: if reply[0] == PKG_SIZE_OWN or reply[0] == PKG_SIZE_DOWNLOAD: self.left_size_label.set_text( _("Size: %s") % bit_to_human_str(reply[1])) elif reply[0] == PKG_SIZE_ERROR: self.left_size_label.set_text("") global_logger.error("Error for calculate pkg size!") else: global_logger.error( "request_pkgs_install_status handle_dbus_error") global_logger.error(reply)
def clean_download_cache_reply(obj, result): num, size = result if num != 0: message = _("You have cleared up %s packages and saved %s of space.") % (num, bit_to_human_str(size)) else: message = _("Your system cache is empty.") global_event.emit("show-message", message, 5000)