Пример #1
0
        def is_correct_pigz_version():
            ver = System.execute('pigz --version')[0][5:]

            logger.debug('Detected pigz version: %s' % (ver, ))
            versionMatches = compareVersions(ver, '>=', '2.2.3')
            logger.debug('pigz version is compatible? %s' % (versionMatches))
            return versionMatches
Пример #2
0
    def checkDependencies(self, productPackageFile):
        for dependency in productPackageFile.packageControlFile.getPackageDependencies(
        ):
            productOnDepots = self._depotBackend._context.productOnDepot_getObjects(
                depotId=self._depotBackend._depotId,
                productId=dependency['package'])
            if not productOnDepots:
                raise BackendUnaccomplishableError(
                    u"Dependent package '%s' not installed" %
                    dependency['package'])

            if not dependency['version']:
                logger.info(u"Fulfilled product dependency '%s'" % dependency)
                continue

            productOnDepot = productOnDepots[0]
            availableVersion = productOnDepot.getProductVersion(
            ) + u'-' + productOnDepot.getPackageVersion()

            if compareVersions(availableVersion, dependency['condition'],
                               dependency['version']):
                logger.info(
                    u"Fulfilled package dependency %s (available version: %s)"
                    % (dependency, availableVersion))
            else:
                raise BackendUnaccomplishableError(
                    u"Unfulfilled package dependency %s (available version: %s)"
                    % (dependency, availableVersion))
Пример #3
0
def getUpdatablePackages(updater):
    """
	Returns information about updatable packages from the given `updater`.


	:raises NoActiveRepositoryError: If not active repositories are found.
	:param updater: The update to use.
	:type updater: OpsiPackageUpdater
	:returns: A dict containing the productId as key and the value is \
another dict with the keys _productId_, _newVersion_, _oldVersion_ and \
_repository_.
	:rtype: {str: {}
	"""
    if not any(updater.getActiveRepositories()):
        raise NoActiveRepositoryError("No active repository configured.")

    updates = {}
    try:
        installedProducts = updater.getInstalledProducts()
        downloadablePackages = updater.getDownloadablePackages()
        downloadablePackages = updater.onlyNewestPackages(downloadablePackages)
        downloadablePackages = updater._filterProducts(downloadablePackages)

        for availablePackage in downloadablePackages:
            productId = availablePackage['productId']
            for product in installedProducts:
                if product['productId'] == productId:
                    logger.debug(u"Product '%s' is installed" % productId)
                    logger.debug(
                        u"Available product version is '%s', installed product version is '%s-%s'"
                        %
                        (availablePackage['version'],
                         product['productVersion'], product['packageVersion']))
                    updateAvailable = compareVersions(
                        availablePackage['version'], '>', '%s-%s' %
                        (product['productVersion'], product['packageVersion']))

                    if updateAvailable:
                        updates[productId] = {
                            "productId":
                            productId,
                            "newVersion":
                            "{version}".format(**availablePackage),
                            "oldVersion":
                            "{productVersion}-{packageVersion}".format(
                                **product),
                            "repository":
                            availablePackage['repository'].name
                        }
                    break
    except Exception as error:
        raise error

    return updates
Пример #4
0
def testPackageVersionsAreComparedAswell(v1, operator, v2):
	assert compareVersions(v1, operator, v2)
Пример #5
0
def testComparisonsWithDifferntDepthsAreMadeTheSameDepth(v1, operator, v2):
	assert compareVersions(v1, operator, v2)
Пример #6
0
def testComparingWorksWithLettersInVersionString(v1, operator, v2):
	assert compareVersions(v1, operator, v2)
Пример #7
0
def testUsingInvalidVersionStringsFails(v1, operator, v2):
	with pytest.raises(ValueError):
		compareVersions(v1, operator, v2)
Пример #8
0
def testIgnoringVersionsWithWaveInThem(v1, operator, v2):
	assert compareVersions(v1, operator, v2)
Пример #9
0
def testUsingUnknownOperatorFails(operator):
	with pytest.raises(ValueError):
		compareVersions('1', operator, '2')
Пример #10
0
def testComparingWithOnlyOneEqualitySign():
	assert compareVersions('1.0', '=', '1.0')
Пример #11
0
def testComparingWithoutGivingOperatorDefaultsToEqual(v1, operator, v2):
	assert compareVersions(v1, operator, v2)
Пример #12
0
def testComparingVersionsOfSameSize(first, operator, second):
	assert compareVersions(first, operator, second)