#!/usr/bin/python ## -*- coding: utf-8 -*- # # «oem-config-remove-gtk» - remove-oem-config after completing # # Copyright (C) 2010, Mario Limonciello # Copyright (C) 2010, Sebastian Heinlein # # # Ubiquity is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free # Software Foundation; either version 2 of the License, or at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this application; if not, write to the Free Software Foundation, Inc., 51 # Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ################################################################################ import os import sys from aptdaemon import client, enums from aptdaemon.gtkwidgets import AptProgressDialog import gobject import gtk loop = gobject.MainLoop() def _on_failure(error): dia = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE, message_format=error.message) dia.run() dia.hide() loop.quit() sys.exit(1) def _on_finished(dia): loop.quit() if dia._transaction.exit == enums.EXIT_SUCCESS: sys.exit(0) else: sys.exit(1) def _on_transaction(trans): apt_dialog = AptProgressDialog(trans) theme = gtk.icon_theme_get_default() apt_dialog.set_icon(icon = theme.load_icon("update-manager", 16, 0)) apt_dialog.set_position('center-always') apt_dialog.run() apt_dialog.connect("finished", _on_finished) def main(): purge = [] for pkg in ('ubiquity', 'ubiquity-casper', 'ubiquity-ubuntu-artwork', 'ubiquity-slideshow-ubuntu'): if os.path.exists("/var/lib/dpkg/info/%s.list" % pkg): purge.append(pkg) ac = client.AptClient() ac.commit_packages([], [], [], purge, [], error_handler=_on_failure, reply_handler=_on_transaction) loop.run() if __name__ == "__main__": main()