| Server IP : 127.0.1.1 / Your IP : 216.73.216.152 Web Server : Apache/2.4.52 (Ubuntu) System : Linux bahcrestlinepropertiesllc 5.15.0-113-generic #123-Ubuntu SMP Mon Jun 10 08:16:17 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3/dist-packages/landscape/lib/ |
Upload File : |
"""Helpers for dealing with software versioning."""
from distutils.version import StrictVersion
def is_version_higher(version1, version2):
"""Check if a version is higher than another.
This takes two software versions in the usual b"x.y" form
and split them on the decimal character, converting both parts
to ints, e.g. b"3.2" becomes (3, 2).
It then does a comparison of the two tuples, and returns C{True} if
C{version1} is greater than or equal to C{version2}.
@param version1: The first version to compare as C{bytes}.
@param version2: The second version to compare as C{bytes}.
@return: C{True} if the first version is greater than or equal to
the second.
"""
version1 = version1.decode("ascii")
version2 = version2.decode("ascii")
return StrictVersion(version1) >= StrictVersion(version2)
def sort_versions(versions):
"""Sort a list of software versions in from the highest to the lowest.
@param version: a C{list} of C{bytes} describing a version.
"""
strict_versions = sorted(
[StrictVersion(version.decode("ascii")) for version in versions],
reverse=True)
return [str(strict_version).encode("ascii")
for strict_version in strict_versions]