Esempio n. 1
0
    def clean_selected_ppa(self):
        self.set_busy()
        # name_list is to display the name of PPA
        # url_list is to identify the ppa
        name_list = []
        url_list = []
        for id in self.get_list():
            #TODO
            try:
                name_list.append(SOURCE_PARSER.get_name(int(id)))
                url_list.append(SOURCE_PARSER.get_url(int(id)))
            except:
                name_list.append(ppa.get_short_name(id))
                url_list.append(id)

        package_view = DowngradeView()
        package_view.update_model(url_list)
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        select_pkgs = package_view.get_downgrade_packages()
        sw.add(package_view)

        #TODO the logic is a little ugly, need to improve the BaseMessageDialog
        if not select_pkgs:
            message = _("It's safe to purge the PPA, no packages need to be downgraded.")
            sw.hide()
        else:
            message = _("To safely purge the PPA, the following packages must be downgraded.")
            sw.show_all()
            sw.set_size_request(500, 100)

        dialog = QuestionDialog(message, title=_("You're going to purge: %s") % ', '.join(name_list))
        dialog.set_resizable(True)
        dialog.vbox.pack_start(sw, True, True, 0)
        dialog.show()

        response = dialog.run()
        dialog.destroy()
        # Workflow
        # 1. Downgrade all the PPA packages to offical packages #TODO Maybe not official? Because anther ppa which is enabled may have newer packages then offical
        # 2. If succeed, disable PPA, or keep it

        if response == gtk.RESPONSE_YES:
            self.set_busy()
            log.debug("The select pkgs is: %s", str(select_pkgs))
            dialog = CleanPpaDialog(self.get_toplevel(), select_pkgs, url_list)
            dialog.run()
            dialog.destroy()
            if dialog.error:
                self.show_failed_dialog(dialog.error)
            else:
                self.show_success_dialog()
            self.update_ppa_model()
            self.unset_busy()
        else:
            self.update_ppa_model()
        # TODO refresh source?
        self.__check_list = []
        self.emit('cleaned')
        self.unset_busy()
Esempio n. 2
0
    def update_ppa_model(self):
        self.set_busy()
        self.__column.set_title('PPA Sources')
        model = self.get_model()
        model.clear()
        self.mode = 'ppa'

        ppa_source_dict = get_ppa_source_dict()

        for source in self.get_sourceslist():
            if ppa.is_ppa(source.uri) and source.type == 'deb' and not source.disabled:
                try:
                    id = ppa_source_dict[source.uri]
                    pixbuf = get_source_logo_from_filename(SOURCE_PARSER[id]['logo'])
                    name = SOURCE_PARSER.get_name(id)
                    comment = SOURCE_PARSER.get_summary(id)
                except:
                    id = source.uri
                    name = ppa.get_short_name(source.uri)
                    comment = ppa.get_homepage(source.uri)
                    pixbuf = get_source_logo_from_filename('')

                self.total_num += 1
                iter = model.append()
                log.debug("Found an enalbed PPA: %s" % name)
                model.set(iter,
                       COLUMN_ICON, pixbuf,
                       COLUMN_CHECK, False,
                       COLUMN_NAME, str(id),
                       COLUMN_DESC, '',
                       COLUMN_DISPLAY, '<b>%s</b>\n%s' % (name, comment),
                    )
        self.unset_busy()
Esempio n. 3
0
    def on_purge_ppa_button_clicked(self, widget):
        # name_list is to display the name of PPA
        # url_list is to identify the ppa
        set_busy(self)
        name_list = []
        url_list = []
        log.debug("self.sourceview.to_purge: %s" % self.sourceview.to_purge)
        for url in self.sourceview.to_purge:
            name_list.append(ppa.get_short_name(url))
            url_list.append(url)

        log.debug("PPAs to purge: url_list: %s" % url_list)

        package_view = DowngradeView(self)
        package_view.update_downgrade_model(url_list)
        sw = Gtk.ScrolledWindow(shadow_type=Gtk.ShadowType.IN)
        sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        select_pkgs = package_view.get_downgrade_packages()
        sw.add(package_view)

        #TODO the logic is a little ugly, need to improve the BaseMessageDialog
        if not select_pkgs:
            message = _(
                "It's safe to purge the PPA, no packages need to be downgraded."
            )
            sw.hide()
        else:
            message = _(
                "To safely purge the PPA, the following packages must be downgraded."
            )
            sw.show_all()
            sw.set_size_request(500, 100)

        dialog = QuestionDialog(title=_("You're going to purge \"%s\":") %
                                ', '.join(name_list),
                                message=message)
        dialog.set_resizable(True)
        dialog.get_content_area().pack_start(sw, True, True, 0)
        dialog.show_all()

        response = dialog.run()
        dialog.destroy()
        # Workflow
        # 1. Downgrade all the PPA packages to offical packages
        #TODO Maybe not official? Because anther ppa which is enabled may have newer packages then offical
        # 2. If succeed, disable PPA, or keep it

        if response == Gtk.ResponseType.YES:
            log.debug("The select pkgs is: %s", str(select_pkgs))
            worker = AptWorker(widget.get_toplevel(),
                               finish_handler=self.on_package_work_finished,
                               data={
                                   'parent': self,
                                   'url_list': url_list
                               })
            worker.downgrade_packages(select_pkgs)
        else:
            unset_busy(self)
Esempio n. 4
0
    def test_ppa(self):
        self.assertTrue(ppa.is_ppa(self.ppa_archive_url))

        list_name = ppa.get_list_name(self.ppa_archive_url)
        self.failUnless(list_name == '' or list_name.startswith('/var/lib/apt/lists/'))

        self.assertEqual(ppa.get_short_name(self.ppa_archive_url), 'ppa:tualatrix/ppa')

        self.assertEqual(ppa.get_homepage(self.ppa_archive_url), self.ppa_home_url)
Esempio n. 5
0
    def get_cruft(self):
        count = 0

        for source in SourcesList():
            if ppa.is_ppa(source.uri) and source.type == 'deb' and not source.disabled:
                count += 1
                name = ppa.get_short_name(source.uri)

                self.emit('find_object', PPAObject(source.uri, name))

        self.emit('scan_finished', True, count, 0)
Esempio n. 6
0
    def test_ppa(self):
        self.assertTrue(ppa.is_ppa(self.ppa_archive_url))

        list_name = ppa.get_list_name(self.ppa_archive_url)
        self.failUnless(list_name == ''
                        or list_name.startswith('/var/lib/apt/lists/'))

        self.assertEqual(ppa.get_short_name(self.ppa_archive_url),
                         'ppa:tualatrix/ppa')

        self.assertEqual(ppa.get_homepage(self.ppa_archive_url),
                         self.ppa_home_url)
Esempio n. 7
0
    def clean_cruft(self, parent, cruft_list):
        set_busy(parent)

        # name_list is to display the name of PPA
        # url_list is to identify the ppa
        name_list = []
        url_list = []
        for cruft in cruft_list:
            name_list.append(ppa.get_short_name(cruft.get_uri()))
            url_list.append(cruft.get_uri())

        package_view = DowngradeView(self)
        package_view.update_model(url_list)
        sw = Gtk.ScrolledWindow(shadow_type=Gtk.ShadowType.IN)
        sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        select_pkgs = package_view.get_downgrade_packages()
        sw.add(package_view)

        #TODO the logic is a little ugly, need to improve the BaseMessageDialog
        if not select_pkgs:
            message = _("It's safe to purge the PPA, no packages need to be downgraded.")
            sw.hide()
        else:
            message = _("To safely purge the PPA, the following packages must be downgraded.")
            sw.show_all()
            sw.set_size_request(500, 100)

        dialog = QuestionDialog(message=message,
                                title=_("You're going to purge: %s") % ', '.join(name_list))
        dialog.set_resizable(True)
        dialog.get_content_area().pack_start(sw, True, True, 0)
        dialog.show()

        response = dialog.run()
        dialog.destroy()
        # Workflow
        # 1. Downgrade all the PPA packages to offical packages
        #TODO Maybe not official? Because anther ppa which is enabled may have newer packages then offical
        # 2. If succeed, disable PPA, or keep it

        if response == Gtk.ResponseType.YES:
            log.debug("The select pkgs is: %s", str(select_pkgs))
            dialog = CleanPpaDialog(parent, select_pkgs, url_list)
            dialog.run()
            dialog.destroy()
            if dialog.error:
                log.error("Error: %s" % dialog.error)
                ErrorDialog(dialog.error).launch()
        # TODO refresh source?

        self.emit('cleaned', True)
        unset_busy(parent)
Esempio n. 8
0
    def on_purge_ppa_button_clicked(self, widget):
        # name_list is to display the name of PPA
        # url_list is to identify the ppa
        set_busy(self)
        name_list = []
        url_list = []
        log.debug("self.sourceview.to_purge: %s" % self.sourceview.to_purge)
        for url in self.sourceview.to_purge:
            name_list.append(ppa.get_short_name(url))
            url_list.append(url)

        log.debug("PPAs to purge: url_list: %s" % url_list)

        package_view = DowngradeView(self)
        package_view.update_downgrade_model(url_list)
        sw = Gtk.ScrolledWindow(shadow_type=Gtk.ShadowType.IN)
        sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        select_pkgs = package_view.get_downgrade_packages()
        sw.add(package_view)

        #TODO the logic is a little ugly, need to improve the BaseMessageDialog
        if not select_pkgs:
            message = _("It's safe to purge the PPA, no packages need to be downgraded.")
            sw.hide()
        else:
            message = _("To safely purge the PPA, the following packages must be downgraded.")
            sw.show_all()
            sw.set_size_request(500, 100)

        dialog = QuestionDialog(title=_("You're going to purge \"%s\":") % ', '.join(name_list),
                                message=message)
        dialog.set_resizable(True)
        dialog.get_content_area().pack_start(sw, True, True, 0)
        dialog.show_all()

        response = dialog.run()
        dialog.destroy()
        # Workflow
        # 1. Downgrade all the PPA packages to offical packages
        #TODO Maybe not official? Because anther ppa which is enabled may have newer packages then offical
        # 2. If succeed, disable PPA, or keep it

        if response == Gtk.ResponseType.YES:
            log.debug("The select pkgs is: %s", str(select_pkgs))
            worker = AptWorker(widget.get_toplevel(),
                               finish_handler=self.on_package_work_finished,
                               data={'parent': self,
                                     'url_list': url_list})
            worker.downgrade_packages(select_pkgs)
        else:
            unset_busy(self)
Esempio n. 9
0
    def update_ppa_model(self):
        self.set_busy()
        self.__column.set_title('PPA Sources')
        model = self.get_model()
        model.clear()
        self.mode = 'ppa'

        ppa_source_dict = get_ppa_source_dict()

        for source in self.get_sourceslist():
            if ppa.is_ppa(source.uri
                          ) and source.type == 'deb' and not source.disabled:
                try:
                    id = ppa_source_dict[source.uri]
                    pixbuf = get_source_logo_from_filename(
                        SOURCE_PARSER[id]['logo'])
                    name = SOURCE_PARSER.get_name(id)
                    comment = SOURCE_PARSER.get_summary(id)
                except:
                    id = source.uri
                    name = ppa.get_short_name(source.uri)
                    comment = ppa.get_homepage(source.uri)
                    pixbuf = get_source_logo_from_filename('')

                self.total_num += 1
                iter = model.append()
                log.debug("Found an enalbed PPA: %s" % name)
                model.set(
                    iter,
                    COLUMN_ICON,
                    pixbuf,
                    COLUMN_CHECK,
                    False,
                    COLUMN_NAME,
                    str(id),
                    COLUMN_DESC,
                    '',
                    COLUMN_DISPLAY,
                    '<b>%s</b>\n%s' % (name, comment),
                )
        self.unset_busy()
Esempio n. 10
0
    def clean_selected_ppa(self):
        self.set_busy()
        # name_list is to display the name of PPA
        # url_list is to identify the ppa
        name_list = []
        url_list = []
        for id in self.get_list():
            #TODO
            try:
                name_list.append(SOURCE_PARSER.get_name(int(id)))
                url_list.append(SOURCE_PARSER.get_url(int(id)))
            except:
                name_list.append(ppa.get_short_name(id))
                url_list.append(id)

        package_view = DowngradeView()
        package_view.update_model(url_list)
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        select_pkgs = package_view.get_downgrade_packages()
        sw.add(package_view)

        #TODO the logic is a little ugly, need to improve the BaseMessageDialog
        if not select_pkgs:
            message = _(
                "It's safe to purge the PPA, no packages need to be downgraded."
            )
            sw.hide()
        else:
            message = _(
                "To safely purge the PPA, the following packages must be downgraded."
            )
            sw.show_all()
            sw.set_size_request(500, 100)

        dialog = QuestionDialog(message,
                                title=_("You're going to purge: %s") %
                                ', '.join(name_list))
        dialog.set_resizable(True)
        dialog.vbox.pack_start(sw, True, True, 0)
        dialog.show()

        response = dialog.run()
        dialog.destroy()
        # Workflow
        # 1. Downgrade all the PPA packages to offical packages #TODO Maybe not official? Because anther ppa which is enabled may have newer packages then offical
        # 2. If succeed, disable PPA, or keep it

        if response == gtk.RESPONSE_YES:
            self.set_busy()
            log.debug("The select pkgs is: %s", str(select_pkgs))
            dialog = CleanPpaDialog(self.get_toplevel(), select_pkgs, url_list)
            dialog.run()
            dialog.destroy()
            if dialog.error == False:
                self.show_success_dialog()
            else:
                self.show_failed_dialog()
            self.update_ppa_model()
            self.unset_busy()
        else:
            self.update_ppa_model()
        # TODO refresh source?
        self.__check_list = []
        self.emit('cleaned')
        self.unset_busy()