Merge pull request #414 from YunoHost/package_version_stable_testing_unstable

Package version stable testing unstable
This commit is contained in:
Laurent Peuch 2018-01-11 14:13:11 +01:00 committed by GitHub
commit 3759df8f06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -414,13 +414,29 @@ def get_installed_version(*pkgnames, **kwargs):
if strict: if strict:
raise UnknownPackage(pkgname) raise UnknownPackage(pkgname)
logger.warning(m18n.n('package_unknown', pkgname=pkgname)) logger.warning(m18n.n('package_unknown', pkgname=pkgname))
continue
try: try:
version = pkg.installed.version version = pkg.installed.version
except AttributeError: except AttributeError:
if strict: if strict:
raise UninstalledPackage(pkgname) raise UninstalledPackage(pkgname)
version = None version = None
versions[pkgname] = version
try:
# stable, testing, unstable
repo = pkg.installed.origins[0].component
except AttributeError:
if strict:
raise UninstalledPackage(pkgname)
repo = ""
versions[pkgname] = {
"version": version,
# when we don't have component it's because it's from a local
# install or from an image (like in vagrant)
"repo": repo if repo else "local",
}
if len(pkgnames) == 1 and not as_dict: if len(pkgnames) == 1 and not as_dict:
return versions[pkgnames[0]] return versions[pkgnames[0]]
@ -436,6 +452,9 @@ def meets_version_specifier(pkgname, specifier):
# YunoHost related methods --------------------------------------------------- # YunoHost related methods ---------------------------------------------------
def ynh_packages_version(*args, **kwargs): def ynh_packages_version(*args, **kwargs):
# from cli the received arguments are:
# (Namespace(_callbacks=deque([]), _tid='_global', _to_return={}), []) {}
# they don't seem to serve any purpose
"""Return the version of each YunoHost package""" """Return the version of each YunoHost package"""
return get_installed_version( return get_installed_version(
'yunohost', 'yunohost-admin', 'moulinette', 'ssowat', 'yunohost', 'yunohost-admin', 'moulinette', 'ssowat',