def uninstall_pkg(self, pkg_name, purge_flag): self.bus_interface.uninstall_pkg(pkg_name, purge_flag, reply_handler=lambda :handle_dbus_reply("uninstall_pkg"), error_handler=lambda e:handle_dbus_error("uninstall_pkg", e)) SendUninstallCount(pkg_name).start() self.install_page.delete_item_match_pkgname(pkg_name)
def request_exit(self): self.exit() self.bus_interface.request_quit( reply_handler=lambda :handle_dbus_reply("request_quit"), error_handler=lambda e:handle_dbus_error("request_quit", e)) data_exit() self.loginfo('Data id removed')
def change_mirror_action(self, mirror): repo_urls = mirror.get_repo_urls() self.bus_interface.change_source_list( repo_urls, reply_handler=lambda :self.handle_mirror_change_reply(mirror), error_handler=lambda e:handle_dbus_error("change_source_list", e) )
def __init__(self, data_manager, pkg_name, alias_name, star, desktop_info, is_installed=None): ''' Initialize ItemIcon class. @param pixbuf: Icon pixbuf. ''' IconItem.__init__(self) self.pkg_name = pkg_name self.alias_name = alias_name self.desktop_info = desktop_info self.star_level = get_star_level(star) self.star_buffer = DscStarBuffer(pkg_name) self.is_installed = is_installed self.grade_star = 0 self.icon_padding_y = 10 self.name_padding_y = 20 self.star_padding_y = 5 self.width = 132 self.height = 150 self.icon_pixbuf = None self.hover_flag = False self.highlight_flag = False self.button_status = BUTTON_NORMAL data_manager.get_pkgs_install_status( [self.pkg_name,], self.update_install_status, lambda e:handle_dbus_error("get_pkgs_install_status", e))
def install_pkgs(self, pkg_names): for pkg_name in pkg_names: self.install_page.download_wait(pkg_name) create_thread(lambda : self.bus_interface.install_pkg( pkg_names, reply_handler=lambda :handle_dbus_reply("install_pkg"), error_handler=lambda e:handle_dbus_error("install_pkg", e))).start() for pkg_name in pkg_names: SendDownloadCount(pkg_name).start()
def finish(source, icon_window, bus_interface, pkg_names): icon_window.destroy() # Send install command. create_thread(lambda : bus_interface.install_pkg( pkg_names, reply_handler=lambda :handle_dbus_reply("install_pkg"), error_handler=lambda e:handle_dbus_error("install_pkg", e))).start() for pkg_name in pkg_names: SendDownloadCount(pkg_name).start()
def run(self): self.ready_show() gtk.main() # Send exit request to backend when frontend exit. self.bus_interface.request_quit( reply_handler=lambda :handle_dbus_reply("request_quit"), error_handler=lambda e:handle_dbus_error("request_quit", e)) # Remove id from config file. data_exit() self.loginfo('Data id removed')
def __init__(self, software_info, data_manager): ''' init docs ''' TreeItem.__init__(self) self.pkg_name = software_info['pkg_name'] self.pkg_title = software_info['short_desc'] self.pkg_summary = software_info['long_desc'] self.alias_name = software_info['display_name'] self.software_pic = software_info['software_pic'] self.desktop_info = data_manager.get_pkg_desktop_info(self.pkg_name) self.install_status = False data_manager.get_pkgs_install_status( [self.pkg_name,], self.update_install_status, lambda :handle_dbus_error("get_pkgs_install_status", self.pkg_name)) FetchImageFromUpyun(self.software_pic, self.update_software_pic).start() self.pixbuf = None self.height = 100 self.button_status = BUTTON_NORMAL
def message_handler(messages, bus_interface, upgrade_page, uninstall_page, install_page, home_page, inhibit_obj): for message in messages: try: (signal_type, action_content) = message if signal_type == "ready-download-start": (pkg_name, action_type) = action_content if action_type == ACTION_INSTALL: install_page.download_ready(pkg_name) elif action_type == ACTION_UPGRADE: upgrade_page.download_ready(pkg_name) elif signal_type == 'ready-download-finish': (pkg_name, action_type) = action_content if action_type == ACTION_INSTALL: install_page.download_wait(pkg_name) elif action_type == ACTION_UPGRADE: upgrade_page.download_wait(pkg_name) elif signal_type == 'pkgs-not-in-cache': (not_in_cache, action_type) = action_content utils.write_log("pkgs-not-in-cache:%s, action_type:%s" % (not_in_cache, action_type)) if action_type == ACTION_INSTALL: pass elif action_type == ACTION_UPGRADE: upgrade_page.upgrading_view.show_error("pkgs_not_in_cache", json.loads(not_in_cache)) elif signal_type == 'pkgs-mark-failed': (pkg_list, action_type) = action_content utils.write_log("pkgs-mark-failed:%s, action_type:%s" % (pkg_list, action_type)) if action_type == ACTION_INSTALL: pass elif action_type == ACTION_UPGRADE: upgrade_page.upgrading_view.show_error("pkgs_mark_failed", pkg_list) elif signal_type == 'marked-delete-system-pkgs': (pkgs, action_type) = action_content utils.write_log("marked-delete-system-pkgs:%s, action_type:%s" % (pkgs, action_type)) if action_type == ACTION_INSTALL: pass elif action_type == ACTION_UPGRADE: upgrade_page.upgrading_view.show_error("marked_delete_system_pkgs", json.loads(pkgs)) elif signal_type == 'pkgs-parse-download-error': (error, action_type) = action_content utils.write_log("pkgs-parse-download-error:%s, action_type:%s" % (error, action_type)) if action_type == ACTION_INSTALL: pass elif action_type == ACTION_UPGRADE: upgrade_page.upgrading_view.show_error("pkgs_parse_download_error", error) elif signal_type == "download-start": (pkg_name, action_type) = action_content if action_type == ACTION_INSTALL: install_page.download_start(pkg_name) elif action_type == ACTION_UPGRADE: upgrade_page.download_start(pkg_name) elif signal_type == "download-update": (pkg_name, action_type, data) = action_content (percent, speed, finish_number, total, downloaded_size, total_size) = data if action_type == ACTION_INSTALL: install_page.download_update(pkg_name, percent, speed) elif action_type == ACTION_UPGRADE: upgrade_page.download_update(pkg_name, percent, speed, finish_number, total, downloaded_size, total_size) elif signal_type == "download-finish": (pkg_name, action_type) = action_content if action_type == ACTION_INSTALL: install_page.download_finish(pkg_name) elif action_type == ACTION_UPGRADE: upgrade_page.download_finish(pkg_name) elif signal_type == "download-stop": (pkg_name, action_type) = action_content if action_type == ACTION_INSTALL: install_page.download_stop(pkg_name) elif action_type == ACTION_UPGRADE: upgrade_page.download_stop(pkg_name) elif signal_type == "download-failed": (pkg_name, action_type, error) = action_content utils.write_log("download-failed:%s, action_type:%s" % (error, action_type)) if action_type == ACTION_INSTALL: install_page.download_failed(pkg_name) elif action_type == ACTION_UPGRADE: upgrade_page.download_failed(pkg_name, error) elif signal_type == "action-start": (pkg_name, action_type) = action_content if action_type == ACTION_UNINSTALL: uninstall_page.action_start(pkg_name) elif action_type == ACTION_UPGRADE: upgrade_page.action_start(pkg_name) elif action_type == ACTION_INSTALL: install_page.action_start(pkg_name) inhibit_obj.set_inhibit() elif signal_type == "action-update": (pkg_name, action_type, percent, status) = action_content if action_type == ACTION_UNINSTALL: uninstall_page.action_update(pkg_name, percent) elif action_type == ACTION_UPGRADE: upgrade_page.action_update(pkg_name, percent, utils.l18n_status_info(status)) elif action_type == ACTION_INSTALL: install_page.action_update(pkg_name, percent) elif signal_type == "action-finish": (pkg_name, action_type, pkg_info_list) = action_content if action_type == ACTION_UNINSTALL: uninstall_page.action_finish(pkg_name, pkg_info_list) utils.show_notify(_("Uninstall %s Successfully.") % pkg_name, _("Uninstall")) elif action_type == ACTION_UPGRADE: upgrade_page.action_finish(pkg_name, pkg_info_list) global_event.emit("upgrade-finish-action", pkg_info_list) utils.set_last_upgrade_time() upgrade_page.refresh_status(pkg_info_list) utils.show_notify(_("%s packages upgrade successfully.") % len(pkg_info_list), _("Upgrade")) elif action_type == ACTION_INSTALL: install_page.action_finish(pkg_name, pkg_info_list) utils.show_notify(_("Install %s Successfully.") % pkg_name, _("Install")) inhibit_obj.unset_inhibit() refresh_current_page_status(pkg_name, pkg_info_list, bus_interface) if action_type != ACTION_UPGRADE: bus_interface.request_status( reply_handler=lambda reply: request_status_reply_hander( reply, install_page, upgrade_page, uninstall_page, pkg_info_list), error_handler=lambda e: action_finish_handle_dbus_error(pkg_info_list), ) elif signal_type == 'action-failed': # FIXME: change failed action dealing (pkg_name, action_type, pkg_info_list, errormsg) = action_content pkg_list = [str(info[0]) for info in pkg_info_list] utils.write_log("action-failed:%s, action_type:%s, pkg_list: %s" % (errormsg, action_type, pkg_list)) if action_type == ACTION_UNINSTALL: uninstall_page.action_finish(pkg_name, pkg_info_list) elif action_type == ACTION_UPGRADE: upgrade_page.upgrading_view.show_error("upgrade_failed", errormsg) utils.set_last_upgrade_time() elif action_type == ACTION_INSTALL: install_page.action_finish(pkg_name, pkg_info_list) inhibit_obj.unset_inhibit() refresh_current_page_status(pkg_name, pkg_info_list, bus_interface) bus_interface.request_status( reply_handler=lambda reply: request_status_reply_hander( reply, install_page, upgrade_page, uninstall_page), error_handler=lambda e:handle_dbus_error("request_status", e), ) elif signal_type == "update-list-update": percent = "[%i%%] " % float(action_content[0]) status = str(action_content[1]) speed_str = str(action_content[2]) status = utils.update_l18n_status_info(status) list_message = [] list_message.append(percent + status) list_message.append(speed_str) global_event.emit("show-message", list_message) elif signal_type == "update-list-merge": global_event.emit("show-message", [_("Generating package list database..."), ''], 0) elif signal_type == "update-list-finish": upgrade_page.fetch_upgrade_info() bus_interface.request_status( reply_handler=lambda reply: request_status_reply_hander(reply, install_page, upgrade_page, uninstall_page), error_handler=lambda e:handle_dbus_error("request_status", e), ) global_event.emit("show-message", [_("Package lists refreshed completely."), ''], 5000) global_event.emit('update-list-finish') global_event.emit("hide-update-list-dialog") elif signal_type == 'update-list-failed': # FIXME: change failed action dealing upgrade_page.fetch_upgrade_info() bus_interface.request_status( reply_handler=lambda reply: request_status_reply_hander(reply, install_page, upgrade_page, uninstall_page), error_handler=lambda e:handle_dbus_error("request_status", e), ) list_message = [] list_message.append(_("Failed to refresh package lists.")) list_message.append(_('Try again')) list_message.append(lambda:global_event.emit('start-update-list')) global_event.emit("show-message", list_message, 0) global_event.emit('update-list-finish') global_event.emit("hide-update-list-dialog") elif signal_type == "parse-download-error": (pkg_name, action_type) = action_content if action_type == ACTION_INSTALL: install_page.download_parse_failed(pkg_name) global_event.emit("show-message", _("Problem occurred when analyzing dependencies for %s. Installation aborted.") % pkg_name) elif action_type == ACTION_UPGRADE: upgrade_page.download_parse_failed(pkg_name) global_event.emit("show-message", _("Problem occurred when analyzing dependencies for %s. Upgrade aborted.") % pkg_name) elif signal_type == "pkg-not-in-cache": pkg_name = action_content list_message = [] list_message.append(_('The requested package \"%s\" was not found in the package list.') % pkg_name) list_message.append(_('Refresh package lists again and try again.')) list_message.append(lambda:global_event.emit('start-update-list')) global_event.emit("show-message", list_message, 0) except Exception, e: traceback.print_exc(file=sys.stdout) print "Message Handler Error:", e
def upgrade_pkgs(self, pkg_names): self.bus_interface.upgrade_pkgs_with_new_policy( pkg_names, reply_handler=lambda :handle_dbus_reply("upgrade_pkgs"), error_handler=lambda e:handle_dbus_error("upgrade_pkgs", e)) return False
def request_update_list(self): self.in_update_list = True self.bus_interface.start_update_list( reply_handler=lambda :handle_dbus_reply("start_update_list"), error_handler=lambda e:handle_dbus_error("start_update_list", e),)
def set_software_download_dir(self): self.bus_interface.set_download_dir( get_software_download_dir(), reply_handler=lambda :handle_dbus_reply("set_download_dir"), error_handler=lambda e:handle_dbus_error("set_download_dir", e))
def dbus_request_status(self): self.bus_interface.request_status( reply_handler=lambda reply: request_status_reply_hander(reply, self.install_page, self.upgrade_page, self.uninstall_page), error_handler=lambda e:handle_dbus_error("request_status", e), )
def init_download_manager(self, v=5): self.bus_interface.init_download_manager( v, reply_handler=lambda :self.init_download_manager_handler(), error_handler=lambda e:handle_dbus_error("init_download_manager", e))
def clean_download_cache(self): self.bus_interface.clean_download_cache( reply_handler=self.clean_download_cache_reply, error_handler=lambda e:handle_dbus_error("clean_download_cache", e), )
def fetch_uninstall_info(self): self.bus_interface.request_uninstall_pkgs( reply_handler=self.render_uninstall_info, error_handler=lambda e:handle_dbus_error("request_uninstall_pkgs", e))
def upgrade_pkgs(self, pkg_names): self.bus_interface.DistUpgrade( pkg_names, reply_handler=lambda :handle_dbus_reply("upgrade_pkgs"), error_handler=lambda e:handle_dbus_error("upgrade_pkgs", e)) return False