我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用apt_pkg.upstream_version()。
def get_upstream_version(package): """Determine upstream version based on installed package @returns None (if not installed) or the upstream version """ import apt_pkg cache = apt_cache() try: pkg = cache[package] except Exception: # the package is unknown to the current apt cache. return None if not pkg.current_ver: # package is known, but no version is currently installed. return None return apt_pkg.upstream_version(pkg.current_ver.ver_str)
def get_upstream_version(package): """Determine upstream version based on installed package @returns None (if not installed) or the upstream version """ import apt_pkg cache = apt_cache() try: pkg = cache[package] except: # the package is unknown to the current apt cache. return None if not pkg.current_ver: # package is known, but no version is currently installed. return None return apt_pkg.upstream_version(pkg.current_ver.ver_str)
def get_upstream_version(package): """Determine upstream version based on installed package @returns None (if not installed) or the upstream version """ import apt_pkg cache = fetch.apt_cache() try: pkg = cache[package] except: # the package is unknown to the current apt cache. return None if not pkg.current_ver: # package is known, but no version is currently installed. return None return apt_pkg.upstream_version(pkg.current_ver.ver_str) # TODO(AJK): Once this is in charms.reactive, drop it here and just reference # the charms.reactive version. # NOTE(AJK): that we are breaking the camalcase rule as this is acting as a # context manager, which doesn't look like a 'class'
def get_version(): """Derive Ceph release from an installed package.""" import apt_pkg as apt cache = apt_cache() package = "ceph" try: pkg = cache[package] except: # the package is unknown to the current apt cache. e = 'Could not determine version of package with no installation ' \ 'candidate: %s' % package error_out(e) if not pkg.current_ver: # package is known, but no version is currently installed. e = 'Could not determine version of uninstalled package: %s' % package error_out(e) vers = apt.upstream_version(pkg.current_ver.ver_str) # x.y match only for 20XX.X # and ignore patch level for other packages match = re.match('^(\d+)\.(\d+)', vers) if match: vers = match.group(0) return float(vers)