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


Python semver.compare方法代码示例

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


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

示例1: python_version_check

# 需要导入模块: import semver [as 别名]
# 或者: from semver import compare [as 别名]
def python_version_check():
    python_version = sys.version.split(' ')[0]

    if not python_version:
        raise TerraformComplianceInternalFailure('Could not determine python version. '
                                                 'Please post this to issues: '.format(sys.version))

    python_version = VersionInfo.parse(python_version)

    if compare(str(python_version), Defaults.supported_min_python_versions) < 0:
        console_write('ERROR: Python version {} is not supported. '
                      'You must have minimum {} version.'.format(python_version,
                                                                 Defaults.supported_min_python_versions[0]))
        sys.exit(1)


    return True 
开发者ID:eerkunt,项目名称:terraform-compliance,代码行数:19,代码来源:helper.py

示例2: _compare_required_versions

# 需要导入模块: import semver [as 别名]
# 或者: from semver import compare [as 别名]
def _compare_required_versions(self):
        """
        Compare installed versions of helm and reckoner to the minimum versions
        required by the course.yml
        Accepts no arguments
        """
        if self.minimum_versions is None:
            return True
        helm_minimum_version = self.minimum_versions.get('helm', '0.0.0')
        reckoner_minimum_version = self.minimum_versions.get('reckoner', '0.0.0')

        logging.debug("Helm Minimum Version is: {}".format(helm_minimum_version))
        logging.debug("Helm Installed Version is {}".format(self.helm.version))

        logging.debug("Reckoner Minimum Version is {}".format(reckoner_minimum_version))
        logging.debug("Reckoner Installed Version is {}".format(reckoner_version))

        r1 = semver.compare(reckoner_version, reckoner_minimum_version)
        if r1 < 0:
            raise MinimumVersionException("reckoner Minimum Version {} not met.".format(reckoner_minimum_version))

        r2 = semver.compare(self.helm.version, helm_minimum_version)
        if r2 < 0:
            raise MinimumVersionException("helm Minimum Version {} not met.".format(helm_minimum_version))

        return True 
开发者ID:FairwindsOps,项目名称:reckoner,代码行数:28,代码来源:course.py

示例3: _is_server_version_greater

# 需要导入模块: import semver [as 别名]
# 或者: from semver import compare [as 别名]
def _is_server_version_greater(self, checked_version):
        return True if semver.compare(self.server_version, checked_version) >= 0 else False 
开发者ID:2gis,项目名称:k8s-handle,代码行数:4,代码来源:deprecation_checker.py

示例4: get_hup_action_type

# 需要导入模块: import semver [as 别名]
# 或者: from semver import compare [as 别名]
def get_hup_action_type(self, device_type, current_version, target_version):
        """
        getHUPActionType in Python
        ref: https://github.com/balena-io-modules/balena-hup-action-utils/blob/master/lib/index.ts#L67
        """

        try:
            parsed_current_ver = semver.parse(current_version)
        except:
            raise exceptions.OsUpdateError('Invalid current balenaOS version')

        try:
            parsed_target_ver = semver.parse(target_version)
        except:
            raise exceptions.OsUpdateError('Invalid target balenaOS version')

        if parsed_current_ver['prerelease'] or parsed_target_ver['prerelease']:
            raise exceptions.OsUpdateError('Updates cannot be performed on pre-release balenaOS versions')

        xstr = lambda s: '' if s is None else str(s)
        if 'dev' in xstr(parsed_current_ver['prerelease']) + xstr(parsed_target_ver['prerelease']) + xstr(parsed_target_ver['build']) + xstr(parsed_current_ver['build']):
            raise exceptions.OsUpdateError('Updates cannot be performed on development balenaOS variants')

        if semver.compare(target_version, current_version) < 0:
            raise exceptions.OsUpdateError('OS downgrades are not allowed')

        # For 1.x -> 2.x or 2.x to 2.x only
        if parsed_target_ver['major'] > 1 and semver.compare(target_version, self.MIN_TARGET_VERSION) < 0:
            raise exceptions.OsUpdateError('Target balenaOS version must be greater than {0}'.format(self.MIN_TARGET_VERSION))

        return 'resinhup{from_v}{to_v}'.format(from_v=parsed_current_ver['major'], to_v=parsed_target_ver['major']) 
开发者ID:balena-io,项目名称:balena-sdk-python,代码行数:33,代码来源:hup.py

示例5: __check_local_mode_supported

# 需要导入模块: import semver [as 别名]
# 或者: from semver import compare [as 别名]
def __check_local_mode_supported(self, device):
        if not self.__is_provisioned_device(device):
            raise exceptions.LocalModeError(Message.DEVICE_NOT_PROVISIONED)

        if semver.compare(self.device_os._DeviceOs__normalize_balena_semver(device['os_version']), LOCAL_MODE_MIN_OS_VERSION) < 0:
            raise exceptions.LocalModeError(Message.DEVICE_OS_NOT_SUPPORT_LOCAL_MODE)

        if semver.compare(self.device_os._DeviceOs__normalize_balena_semver(device['supervisor_version']), LOCAL_MODE_MIN_SUPERVISOR_VERSION) < 0:
            raise exceptions.LocalModeError(Message.DEVICE_SUPERVISOR_NOT_SUPPORT_LOCAL_MODE)

        if device['os_variant'] != 'dev':
            raise exceptions.LocalModeError(Message.DEVICE_OS_TYPE_NOT_SUPPORT_LOCAL_MODE) 
开发者ID:balena-io,项目名称:balena-sdk-python,代码行数:14,代码来源:device.py

示例6: _compare_required_versions

# 需要导入模块: import semver [as 别名]
# 或者: from semver import compare [as 别名]
def _compare_required_versions(self):
        """
        Compare installed versions of helm and autohelm to the minimum versions
        required by the course.yml
        Accepts no arguments
        """
        if self.minimum_versions is None:
            return True
        helm_minimum_version = self.minimum_versions.get('helm', '0.0.0')
        autohelm_minimum_version = self.minimum_versions.get('autohelm', '0.0.0')

        logging.debug("Helm Minimum Version is: {}".format(helm_minimum_version))
        logging.debug("Helm Installed Version is {}".format(self.helm.client_version))

        logging.debug("Autohelm Minimum Version is {}".format(autohelm_minimum_version))
        logging.debug("Autohelm Installed Version is {}".format(autohelm_version))

        r1 = semver.compare(autohelm_version, autohelm_minimum_version)
        if r1 < 0:
            raise MinimumVersionException("autohelm Minimum Version {} not met.".format(autohelm_minimum_version))

        if not self.config.local_development:
            r2 = semver.compare(self.helm.client_version, helm_minimum_version)
            if r2 < 0:
                raise MinimumVersionException("helm Minimum Version {} not met.".format(helm_minimum_version))

        return True 
开发者ID:FairwindsOps,项目名称:autohelm,代码行数:29,代码来源:course.py

示例7: main

# 需要导入模块: import semver [as 别名]
# 或者: from semver import compare [as 别名]
def main():
    """lets start our task"""
    # clone the repo
    cleanup(LOCAL_WORK_COPY)
    try:
        r = Repo.clone_from(git_url, LOCAL_WORK_COPY)
    except GitCommandError as git_error:
        print(git_error)
        exit(-1)

    d = feedparser.parse(
        'https://github.com/mattermost/mattermost-server/releases.atom')
    release_version = d.entries[0].title[1:]

    # lets read the dockerfile of the current master
    dfp = DockerfileParser()

    with open('./mattermost-openshift-workdir/Dockerfile') as f:
        dfp.content = f.read()

    if 'MATTERMOST_VERSION' in dfp.envs:
        dockerfile_version = dfp.envs['MATTERMOST_VERSION']

    # Lets check if we got a new release
    if semver.compare(release_version, dockerfile_version) == 1:
        print("Updating from %s to %s" % (dockerfile_version, release_version))

        target_branch = 'bots-life/update-to-' + release_version

        if not pr_in_progress(target_branch):
            patch_and_push(dfp, r, target_branch, release_version)
            cleanup(LOCAL_WORK_COPY)

            create_pr_to_master(target_branch)
        else:
            print("There is an open PR for %s, aborting..." %
                  (target_branch))

    else:
        print("we are even with Mattermost %s, no need to update" %
              release_version) 
开发者ID:goern,项目名称:mattermost-openshift,代码行数:43,代码来源:pr_from_new_release.py

示例8: test_ensure_os_version

# 需要导入模块: import semver [as 别名]
# 或者: from semver import compare [as 别名]
def test_ensure_os_version(mock_wait_for_device, mock_get_os, mock_install_os, mock_time, device, cli_args):
    results = 'test result message'
    device.api.execute.return_value = (True, results)
    ver_required = '3.1.2'
    device_semver = semver.parse_version_info(device.facts['os_version'])
    image_name = 'image_file_name'

    def mock_get_os_function():
        diff = semver.compare(device.facts['os_version'], ver_required)
        # Check if upgrade is required
        if diff < 0:
            # upgrade required
            local_cb.image_name = image_name
        else:
            # upgrade not required
            local_cb.image_name = None
    mock_get_os.side_effect = mock_get_os_function
    local_cb = cumulus_bootstrap.CumulusBootstrap(args['server'], cli_args)
    local_cb.dev = device
    local_cb.ensure_os_version()

    # If upgrade was required, check that the correct calls were made
    if local_cb.image_name:
        assert mock_install_os.called_with(mock.call(device), image_name=image_name)
        if device_semver < (3, 0, 0):
            device.api.execute.assert_called_with(['sudo reboot'])
            mock_wait_for_device.assert_called_with(countdown=local_cb.cli_args.reload_delay, poll_delay=10)
        else:
            # Ensure device was not rebooted if v3 or greater, and wait_for_device was called
            assert not device.api.execute.called
    else:
        assert not device.api.execute.called
        assert not mock_install_os.called 
开发者ID:Apstra,项目名称:aeon-ztps,代码行数:35,代码来源:test_cumulus_bootstrap.py

示例9: migrate

# 需要导入模块: import semver [as 别名]
# 或者: from semver import compare [as 别名]
def migrate(branch='migration', yes=False):
    """ Find applicable migrations and run them """
    logging.info("Pentagon Version: {}".format(installed_version()))
    logging.info("Starting Repository Version: {}".format(current_version()))

    migrations = migrations_to_run(current_version(), available_migrations())
    if migrations:
        logging.info("There are Migrations to run: ")
        logging.info(migrations)
        if yes:
            for migration in migrations:
                logging.info('Starting migration: {}'.format(migration))
                migration_name = "migration_{}".format(migration.replace('.', '_'))
                migration_class = locate("pentagon.migration.migrations.{}".format(migration_name))
                migration_class.Migration(branch).start()
            logging.info("Migrations complete. Use git to merge the migration branch.")
            logging.info("Current Repository Version: {}".format(current_version()))
        else:
            logging.info("Use: `pentagon migrate --yes` to run migrations")
    else:
        logging.info("No Migrations to run.")
        compare_value = semver.compare(installed_version(), current_version())
        if compare_value == -1:
            logging.error("Repository Version > Installed Version. Upgrade Pentagon")
            sys.exit(1)
        elif compare_value == 1:
            logging.info("Installed Version > Repository Version.")
            logging.info(" Use `pentagon migrate --yes` to update Repository Version")
            if yes:
                Migration(None).version_only()
        elif compare_value == 0:
            logging.info("You are at the latest version!") 
开发者ID:FairwindsOps,项目名称:pentagon,代码行数:34,代码来源:__init__.py

示例10: update_recommendations

# 需要导入模块: import semver [as 别名]
# 或者: from semver import compare [as 别名]
def update_recommendations(vulnerabilities):
        recommendations = dict()
        for vuln in vulnerabilities:
            # dotnet issues don't have upgrades
            if not vuln['upgrades']:
                continue
            if vuln['from'][1] not in recommendations:
                recommendations[vuln['from'][1]] = vuln['upgrades'][1]
            else:

                module = vuln['upgrades'][1][:vuln['upgrades'][1].rfind('@')]
                if semver.compare(vuln['upgrades'][1].split('@')[-1], recommendations[vuln['from'][1]].split('@')[-1],
                                  loose=True) == -1:
                    max_version = recommendations[vuln['from'][1]].split('@')[-1]
                else:
                    max_version = vuln['upgrades'][1].split('@')[-1]
                recommendations[vuln['from'][1]] = '@'.join([module, max_version])
        for vuln in vulnerabilities:
            if vuln['language'] == 'dotnet':
                vuln['Recommendations'] = f'Upgrade `{vuln["top_level_module"]}` to the latest compatible version.'
                continue
            if semver.compare(vuln['from'][1].split("@")[-1], recommendations[vuln['from'][1]].split("@")[-1],
                              loose=True) == -1:
                vuln['Recommendations'] = (f'Upgrade `{vuln["top_level_module"]}` '
                                           f'to version {recommendations[vuln["from"][1]].split("@")[-1]} or higher')
            else:
                vuln['Recommendations'] = (f'Your dependencies are out of date. Please remove your `node_modules` '
                                           f'directory and lock file, run `npm install` and commit new lock file to '
                                           f'your repo. Note, this will likely make a lot of changes to lock file.') 
开发者ID:dowjones,项目名称:reapsaw,代码行数:31,代码来源:SnykReport.py

示例11: version_compare

# 需要导入模块: import semver [as 别名]
# 或者: from semver import compare [as 别名]
def version_compare(value, pattern):
    return semver.compare(value, pattern) 
开发者ID:StackStorm,项目名称:st2,代码行数:4,代码来源:version.py

示例12: version_more_than

# 需要导入模块: import semver [as 别名]
# 或者: from semver import compare [as 别名]
def version_more_than(value, pattern):
    return semver.compare(value, pattern) == 1 
开发者ID:StackStorm,项目名称:st2,代码行数:4,代码来源:version.py

示例13: version_less_than

# 需要导入模块: import semver [as 别名]
# 或者: from semver import compare [as 别名]
def version_less_than(value, pattern):
    return semver.compare(value, pattern) == -1 
开发者ID:StackStorm,项目名称:st2,代码行数:4,代码来源:version.py

示例14: version_equal

# 需要导入模块: import semver [as 别名]
# 或者: from semver import compare [as 别名]
def version_equal(value, pattern):
    return semver.compare(value, pattern) == 0 
开发者ID:StackStorm,项目名称:st2,代码行数:4,代码来源:version.py

示例15: _skip_max_docker_ver

# 需要导入模块: import semver [as 别名]
# 或者: from semver import compare [as 别名]
def _skip_max_docker_ver(ver):
    try:
        return compare(DOCKER_VERSION, ver) < 0
    except ValueError:
        return False 
开发者ID:ClusterHQ,项目名称:dvol,代码行数:7,代码来源:testtools.py


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