当前位置: 首页>>代码示例>>Python>>正文


Python DebPackage.compare_to_version_in_cache方法代码示例

本文整理汇总了Python中apt.debfile.DebPackage.compare_to_version_in_cache方法的典型用法代码示例。如果您正苦于以下问题:Python DebPackage.compare_to_version_in_cache方法的具体用法?Python DebPackage.compare_to_version_in_cache怎么用?Python DebPackage.compare_to_version_in_cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在apt.debfile.DebPackage的用法示例。


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

示例1: installdeb

# 需要导入模块: from apt.debfile import DebPackage [as 别名]
# 或者: from apt.debfile.DebPackage import compare_to_version_in_cache [as 别名]
 def installdeb(self, pkg):
     """
     Install the Debian package.
     
     :param pkg: The path to the package to install
     :type  pkg: str
     """
     
     # Get the DebPackage object and the filename
     dpkg     = DebPackage(filename=pkg, cache=self.cache)
     pkg_name = basename(pkg)
         
     # Look for package conflicts
     if not dpkg.check_conflicts():
         self.feedback.block(dpkg.conflicts, 'CONFLICT')
         self.feedback.error('Cannot install package <{0}>, conflicts with:'.format(pkg_name))
         return False
     
     # Get any version in cache
     cache_version = dpkg.compare_to_version_in_cache()
     action        = 'Installed'
     
     # Not installed
     if cache_version == dpkg.VERSION_NONE:
         self.feedback.info('Package <{0}> not installed'.format(pkg_name))
         
     # Upgrading
     if cache_version == dpkg.VERSION_OUTDATED:
         self.feedback.info('Package <{0}> outdated, upgrading'.format(pkg_name))
         action = 'Updated'
         
     # Same version
     if cache_version == dpkg.VERSION_SAME:
         return self.feedback.info('Package <{0}> already installed'.format(pkg_name))
     
     # Installed is newer
     if cache_version == dpkg.VERSION_NEWER:
         return self.feedback.info('Package <{0}> has newer version installed'.format(pkg_name))
         
     # Install the package
     dpkg.install()
     self.feedback.success('{0}: {1}'.format(action, pkg_name))
开发者ID:pombredanne,项目名称:lense-devtools,代码行数:44,代码来源:dpkg.py

示例2: AppDetailsDebFile

# 需要导入模块: from apt.debfile import DebPackage [as 别名]
# 或者: from apt.debfile.DebPackage import compare_to_version_in_cache [as 别名]
class AppDetailsDebFile(AppDetails):

    def __init__(self, db, doc=None, application=None):
        super(AppDetailsDebFile, self).__init__(db, doc, application)
        if doc:
            raise ValueError("doc must be None for deb files")

        try:
            with ExecutionTime("create DebPackage"):
                # Cache() used to be faster here than self._cache._cache
                # but that is no longer the case with the latest apt
                self._deb = DebPackage(self._app.request, self._cache._cache)
        except:
            self._deb = None
            self._pkg = None
            if not os.path.exists(self._app.request):
                self._error = _("Not found")
                self._error_not_found = utf8(_(u"The file \u201c%s\u201d "
                    "does not exist.")) % utf8(self._app.request)
            else:
                mimetype = guess_type(self._app.request)
                if mimetype[0] != "application/x-debian-package":
                    self._error = _("Not found")
                    self._error_not_found = utf8(_(u"The file \u201c%s\u201d "
                        "is not a software package.")) % utf8(
                        self._app.request)
                else:
                    # deb files which are corrupt
                    self._error = _("Internal Error")
                    self._error_not_found = utf8(_(u"The file \u201c%s\u201d "
                        "could not be opened.")) % utf8(self._app.request)
            return

        if self.pkgname and self.pkgname != self._app.pkgname:
            # this happens when the deb file has a quirky file name
            self._app.pkgname = self.pkgname

            # load pkg cache
            self._pkg = None
            if (self._app.pkgname in self._cache and
                self._cache[self._app.pkgname].candidate):
                self._pkg = self._cache[self._app.pkgname]
            # load xapian document
            self._doc = None
            try:
                self._doc = self._db.get_xapian_document(
                    self._app.appname, self._app.pkgname)
            except:
                pass

        # check deb and set failure state on error
        with ExecutionTime("AppDetailsDebFile._deb.check()"):
            if not self._deb.check():
                self._error = self._deb._failure_string.strip()

    @property
    def description(self):
        if self._deb:
            description = self._deb._sections["Description"]
            s = ('\n').join(description.split('\n')[1:]).replace(" .\n", "")
            return utf8(s)
        return ""

    @property
    def maintenance_status(self):
        pass

    @property
    def pkgname(self):
        if self._deb:
            return self._deb._sections["Package"]

    @property
    def pkg_state(self):
        if self._error:
            if self._error_not_found:
                return PkgStates.NOT_FOUND
            else:
                return PkgStates.ERROR
        if self._deb:
            deb_state = self._deb.compare_to_version_in_cache()
            if deb_state == DebPackage.VERSION_NONE:
                return PkgStates.UNINSTALLED
            elif deb_state == DebPackage.VERSION_OUTDATED:
                if self._cache[self.pkgname].installed:
                    return PkgStates.INSTALLED
                else:
                    return PkgStates.UNINSTALLED
            elif deb_state == DebPackage.VERSION_SAME:
                return PkgStates.REINSTALLABLE
            elif deb_state == DebPackage.VERSION_NEWER:
                if self._cache[self.pkgname].installed:
                    return PkgStates.UPGRADABLE
                else:
                    return PkgStates.UNINSTALLED

    @property
    def summary(self):
        if self._deb:
            description = self._deb._sections["Description"]
#.........这里部分代码省略.........
开发者ID:feiying,项目名称:AppStream,代码行数:103,代码来源:debfile.py

示例3: DebFile

# 需要导入模块: from apt.debfile import DebPackage [as 别名]
# 或者: from apt.debfile.DebPackage import compare_to_version_in_cache [as 别名]
class DebFile(AbstractPackageFile):

    def __init__(self, deb_file):
        AbstractPackageFile.__init__(self, deb_file)
        self.package = DebPackage(deb_file, CACHE)
        self.package.check()

    def is_source(self):
        try:
            self.package['Source']
        except KeyError as exception:
            if self.arch == 'source':
                return True
            else:
                return False
        return True

    @property
    def requires(self):
        return self.package.depends

    @property
    def arch(self):
        return self.package['Architecture']

    @property
    def name(self):
        return self.package.pkgname

    @property
    def license(self):
        try:
            return self.package['License']
        except KeyError as _:
            pass

    @property
    def conflicts(self):
        return self.package.conflicts

    @property
    def version(self):
        return self.package['Version']

    @property
    def summary(self):
        return self.description

    @property
    def upgradable(self):
        return super(DebFile, self).upgradable()

    @property
    def provides(self):
        return self.package.provides

    @property
    def platform(self):
        return None

    @property
    def description(self):
        return self.package['Description']

    @property
    def installed(self):
        return self.package.compare_to_version_in_cache() \
               != DebPackage.VERSION_NONE

    @property
    def release(self):
        try:
            return self.package['Distribution']
        except KeyError as _:
            return 'unstable'
开发者ID:pussbb,项目名称:sx-installer,代码行数:77,代码来源:deb.py


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