• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python package.AptWorker类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中ubuntutweak.utils.package.AptWorker的典型用法代码示例。如果您正苦于以下问题:Python AptWorker类的具体用法?Python AptWorker怎么用?Python AptWorker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AptWorker类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: on_apply_button_clicked

    def on_apply_button_clicked(self, widget, data=None):
        @log_func(log)
        def on_install_finished(transaction, status, kwargs):
            to_add, to_rm = kwargs['add_and_rm']
            if to_rm:
                worker = AptWorker(self.get_toplevel(),
                                   finish_handler=self.on_package_work_finished,
                                   data=kwargs)
                worker.remove_packages(to_rm)
            else:
               self.on_package_work_finished(None, None, kwargs)

        to_rm = self.appview.to_rm
        to_add = self.appview.to_add

        log.debug("on_apply_button_clicked: to_rm: %s, to_add: %s" % (to_rm, to_add))

        if to_add or to_rm:
            set_busy(self)

            if to_add:
                worker = AptWorker(self.get_toplevel(),
                                   finish_handler=on_install_finished,
                                   data={'add_and_rm': (to_add, to_rm),
                                         'parent': self})
                worker.install_packages(to_add)
            else:
                on_install_finished(None, None, 
                                   {'add_and_rm': (to_add, to_rm),
                                         'parent': self})
开发者ID:c326277320,项目名称:ubuntu-tweak,代码行数:30,代码来源:appcenter.py


示例2: clean_cruft

 def clean_cruft(self, parent=None, cruft_list=[]):
     set_busy(parent)
     worker = AptWorker(parent,
                        finish_handler=self.on_clean_finished,
                        error_handler=self.on_error,
                        data=parent)
     worker.remove_packages([cruft.get_package_name() for cruft in cruft_list])
开发者ID:0tli4nitsa,项目名称:ubuntu-tweak,代码行数:7,代码来源:autoremoval_plugin.py


示例3: on_install_finished

 def on_install_finished(transaction, status, kwargs):
     to_add, to_rm = kwargs['add_and_rm']
     if to_rm:
         worker = AptWorker(self.get_toplevel(),
                            finish_handler=self.on_package_work_finished,
                            data=kwargs)
         worker.remove_packages(to_rm)
     else:
        self.on_package_work_finished(None, None, kwargs)
开发者ID:c326277320,项目名称:ubuntu-tweak,代码行数:9,代码来源:appcenter.py


示例4: do_action_for_app

    def do_action_for_app(self, pkgname, action_id, *args):
        action_id = int(action_id)

        if action_id == self.INSTALL_ACTION:
            set_busy(self)
            worker = AptWorker(self.get_toplevel(),
                               finish_handler=self.on_package_work_finished,
                               data={'parent': self})
            worker.install_packages([pkgname])

            self.update_action_button(self.INSTALLING_ACTION)
        elif action_id == self.UNINSTALL_ACTION:
            set_busy(self)
            worker = AptWorker(self.get_toplevel(),
                               finish_handler=self.on_package_work_finished,
                               data={'parent': self})
            worker.remove_packages([pkgname])

            self.update_action_button(self.UNINSTALLING_ACTION)
        elif action_id == self.UPDATE_ACTION:
            set_busy(self)
            worker = AptWorker(self.get_toplevel(),
                               finish_handler=self.on_update_work_finished,
                               data={'parent': self})
            worker.update_cache()
            self.update_action_button(self.UPDATING_ACTION)
开发者ID:billy3321,项目名称:ubuntu-tweak,代码行数:26,代码来源:__init__.py


示例5: on_package_work_finished

    def on_package_work_finished(self, transaction, status, add_and_rm):
        to_add, to_rm = add_and_rm

        AptWorker.update_apt_cache(init=True)

        self.emit('call', 'ubuntutweak.modules.updatemanager', 'update_list', {})

        self.appview.to_add = []
        self.appview.to_rm = []
        self.appview.clear_model()
        self.appview.update_model()
开发者ID:nayanapriyankara,项目名称:ubuntu-tweak,代码行数:11,代码来源:appcenter.py


示例6: on_update_work_finished

 def on_update_work_finished(self, transaction, status, kwargs):
     parent = kwargs["parent"]
     proxy.update_apt_cache(True)
     if proxy.is_package_upgradable(self.current_app) or (
         not proxy.is_package_installed(self.current_app) and proxy.is_package_avaiable(self.current_app)
     ):
         worker = AptWorker(self.get_toplevel(), finish_handler=self.on_package_work_finished, data={"parent": self})
         worker.install_packages([self.current_app])
     else:
         unset_busy(parent)
         self.reset_install_button()
开发者ID:302sk,项目名称:ubuntu-tweak,代码行数:11,代码来源:__init__.py


示例7: on_package_work_finished

    def on_package_work_finished(self, transaction, status, kwargs):
        to_add, to_rm = kwargs['add_and_rm']
        parent = kwargs['parent']

        AptWorker.update_apt_cache(init=True)

        self.emit('call', 'ubuntutweak.modules.updatemanager', 'update_list', {})

        self.appview.to_add = []
        self.appview.to_rm = []
        self.on_category_changed(self.cateview.get_selection())
        self.apply_button.set_sensitive(False)
        unset_busy(parent)
开发者ID:c326277320,项目名称:ubuntu-tweak,代码行数:13,代码来源:appcenter.py


示例8: on_purge_ppa_button_clicked

    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)
开发者ID:0xBADCA7,项目名称:ubuntu-tweak,代码行数:51,代码来源:sourcecenter.py


示例9: on_update_button_clicked

    def on_update_button_clicked(self, widget):
        @log_func(log)
        def on_update_finished(transaction, status, parent):
            log.debug("on_update_finished")
            unset_busy(parent)

        set_busy(self)
        daemon = AptWorker(widget.get_toplevel(),
                           finish_handler=on_update_finished,
                           data=self)
        daemon.update_cache()

        self.emit('call', 'ubuntutweak.modules.appcenter', 'update_app_data', {})
        self.emit('call', 'ubuntutweak.modules.updatemanager', 'update_list', {})
开发者ID:0xBADCA7,项目名称:ubuntu-tweak,代码行数:14,代码来源:sourcecenter.py


示例10: on_apply_button_clicked

    def on_apply_button_clicked(self, widget, data = None):
        def on_clean_finished(transaction, status, add_and_rm):
            to_add, to_rm = add_and_rm
            worker = AptWorker(self.get_toplevel(), self.on_package_work_finished, add_and_rm)
            worker.remove_packages(to_rm)

        to_rm = self.appview.to_rm
        to_add = self.appview.to_add

        log.debug("on_apply_button_clicked: to_rm: %s, to_add: %s" % (to_rm, to_add))

        if to_add or to_rm:
            if to_add:
                #TODO if user cancel auth
                if to_rm:
                    worker = AptWorker(self.get_toplevel(), on_clean_finished, (to_add, to_rm))
                else:
                    worker = AptWorker(self.get_toplevel(), self.on_package_work_finished, (to_add, to_rm))
                worker.install_packages(to_add)
            elif to_rm:
                on_clean_finished(None, None, to_rm)
开发者ID:nayanapriyankara,项目名称:ubuntu-tweak,代码行数:21,代码来源:appcenter.py


示例11: get_cruft

    def get_cruft(self):
        cache = AptWorker.get_cache()
        count = 0
        size = 0
        if cache:
            for pkg in cache:
                if pkg.isAutoRemovable:
                    count += 1
                    size += pkg.installedSize
                    self.emit('find_object',
                              PackageObject(pkg.summary, pkg.name, pkg.installedSize))

        self.emit('scan_finished', True, count, size)
开发者ID:nayanapriyankara,项目名称:ubuntu-tweak,代码行数:13,代码来源:autoremoval_plugin.py


示例12: get_cruft

    def get_cruft(self):
        cache = AptWorker.get_cache()
        count = 0
        size = 0
        if cache:
            for pkg in cache:
                if pkg.is_auto_removable and not pkg.name.startswith('linux'):
                    count += 1
                    size += pkg.installed.size
                    self.emit('find_object',
                              PackageObject(pkg.installed.summary, pkg.name, pkg.installed.size),
                              count)

        self.emit('scan_finished', True, count, size)
开发者ID:0xBADCA7,项目名称:ubuntu-tweak,代码行数:14,代码来源:autoremoval_plugin.py


示例13: get_cruft

    def get_cruft(self):
        cache = AptWorker.get_cache()
        count = 0
        size = 0

        if cache:
            for pkg in cache:
                if pkg.isInstalled and self.is_old_kernel_package(pkg.name):
                    log.debug("Find old kernerl: %s" % pkg.name)
                    count += 1
                    size += pkg.installedSize
                    self.emit('find_object',
                              PackageObject(pkg.name, pkg.name, pkg.installedSize))

        self.emit('scan_finished', True, count, size)
开发者ID:nayanapriyankara,项目名称:ubuntu-tweak,代码行数:15,代码来源:oldkernel_plugin.py


示例14: get_cruft

    def get_cruft(self):
        try:
            cache = AptWorker.get_cache()
            count = 0
            size = 0

            if cache:
                for pkg in cache:
                    if pkg.isInstalled and self.is_old_kernel_package(pkg.name):
                        log.debug("Find old kernerl: %s" % pkg.name)
                        count += 1
                        size += pkg.installedSize
                        self.emit('find_object',
                                  PackageObject(pkg.name, pkg.name, pkg.installedSize),
                                  count)

            self.emit('scan_finished', True, count, size)
        except Exception, e:
            error = get_traceback()
            log.error(error)
            self.emit('scan_error', error)
开发者ID:itachi46,项目名称:ubuntu-tweak,代码行数:21,代码来源:oldkernel_plugin.py


示例15: get_downgradeable_pkgs

    def get_downgradeable_pkgs(self, ppa_dict):
        def is_system_origin(version, urls):
            origins = [ppa.get_ppa_origin_name(url) for url in urls]
            system_version = 0
            match = False

            for origin in version.origins:
                if origin.origin:
                    if origin.origin not in origins:
                        log.debug("The origin %s is not in %s, so end the loop" % (origin.origin, str(origins)))
                        match = True
                        break

            if match:
                system_version = version.version
                log.debug("Found match url, the system_version is %s, now iter to system version" % system_version)

            return system_version

        def is_full_match_ppa_origin(pkg, version, urls):
            origins = [ppa.get_ppa_origin_name(url) for url in urls]
            ppa_version = 0
            match = True

            if version == pkg.installed:
                for origin in version.origins:
                    if origin.origin:
                        if origin.origin not in origins:
                            log.debug("The origin %s is not in %s, so end the loop" % (origin.origin, str(origins)))
                            match = False
                            break

                if match:
                    ppa_version = version.version
                    log.debug("Found match url, the ppa_version is %s, now iter to system version" % ppa_version)

            return ppa_version

        log.debug("Check downgrade information")
        downgrade_dict = {}
        for pkg, urls in ppa_dict.items():
            log.debug("The package is: %s, PPA URL is: %s" % (pkg, str(urls)))

            if pkg not in AptWorker.get_cache():
                log.debug("    package isn't available, continue next...\n")
                continue

            pkg = AptWorker.get_cache()[pkg]
            if not pkg.isInstalled:
                log.debug("    package isn't installed, continue next...\n")
                continue
            versions = pkg.versions

            ppa_version = 0
            system_version = 0
            FLAG = 'PPA'
            try:
                for version in versions:
                    try:
                        #FIXME option to remove the package
                        log.debug("Version uri is %s" % version.uri)

                        # Switch FLAG
                        if FLAG == 'PPA':
                            ppa_version = is_full_match_ppa_origin(pkg, version, urls)
                            FLAG = 'SYSTEM'
                            if ppa_version == 0:
                                raise NoNeedDowngradeException
                        else:
                            system_version = is_system_origin(version, urls)

                        if ppa_version and system_version:
                            downgrade_dict[pkg.name] = (ppa_version, system_version)
                            break
                    except StopIteration:
                        pass
            except NoNeedDowngradeException:
                log.debug("Catch NoNeedDowngradeException, so pass this package: %s" % pkg)
                continue
            log.debug("\n")
        return downgrade_dict
开发者ID:0xBADCA7,项目名称:ubuntu-tweak,代码行数:81,代码来源:sourcecenter.py


示例16: on_update_button_clicked

    def on_update_button_clicked(self, widget):
        daemon = AptWorker(widget.get_toplevel())
        daemon.update_cache()

        self.emit('call', 'ubuntutweak.modules.appcenter', 'update_app_data', {})
        self.emit('call', 'ubuntutweak.modules.updatemanager', 'update_list', {})
开发者ID:nayanapriyankara,项目名称:ubuntu-tweak,代码行数:6,代码来源:sourcecenter.py


示例17: on_update_button_clicked

 def on_update_button_clicked(self, widget):
     self.set_busy()
     daemon = AptWorker(widget.get_toplevel(), lambda t, s, d: self.unset_busy())
     daemon.update_cache()
开发者ID:Thongor,项目名称:ubuntu-tweak,代码行数:4,代码来源:sourceeditor.py


示例18: on_clean_finished

 def on_clean_finished(transaction, status, add_and_rm):
     to_add, to_rm = add_and_rm
     worker = AptWorker(self.get_toplevel(), self.on_package_work_finished, add_and_rm)
     worker.remove_packages(to_rm)
开发者ID:nayanapriyankara,项目名称:ubuntu-tweak,代码行数:4,代码来源:appcenter.py


示例19: on_clean_finished

 def on_clean_finished(self, transaction, status, parent):
     unset_busy(parent)
     AptWorker.update_apt_cache(True)
     self.emit('cleaned', True)
开发者ID:nayanapriyankara,项目名称:ubuntu-tweak,代码行数:4,代码来源:oldkernel_plugin.py


示例20: __init__

 def __init__(self, name):
     self.name = name
     self.pkg = AptWorker.get_cache()[name]
     self.desktopentry = DesktopEntry(self.DESKTOP_DIR + name + '.desktop')
开发者ID:c326277320,项目名称:ubuntu-tweak,代码行数:4,代码来源:appcenter.py



注:本文中的ubuntutweak.utils.package.AptWorker类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python dialogs.QuestionDialog类代码示例发布时间:2022-05-27
下一篇:
Python icon.get_from_name函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap