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


Python SaltStackVersion.parse方法代码示例

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


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

示例1: test_version_comparison

# 需要导入模块: from salt.version import SaltStackVersion [as 别名]
# 或者: from salt.version.SaltStackVersion import parse [as 别名]
 def test_version_comparison(self):
     examples = (
         ('debian/0.11.1+ds-1-3-ga0afcbd', '0.11.1+ds-2'),
         ('v0.12.0-85-g2880105', 'v0.12.0-19-g767d4f9'),
         ('v0.17.0rc1-1-g52ebdfd', '0.17.0rc1'),
         ('v0.17.0', 'v0.17.0rc1')
     )
     for v1, v2 in examples:
         self.assertTrue(SaltStackVersion.parse(v1) > v2)
         self.assertTrue(SaltStackVersion.parse(v2) < v1)
开发者ID:joehealy,项目名称:pkg-salt,代码行数:12,代码来源:version_test.py

示例2: test_version_comparison

# 需要导入模块: from salt.version import SaltStackVersion [as 别名]
# 或者: from salt.version.SaltStackVersion import parse [as 别名]
 def test_version_comparison(self):
     examples = (
         ('debian/0.11.1+ds-1-3-ga0afcbd', '0.11.1+ds-2'),
         ('v0.12.0-85-g2880105', 'v0.12.0-19-g767d4f9'),
         ('v0.17.0rc1-1-g52ebdfd', '0.17.0rc1'),
         ('v0.17.0', 'v0.17.0rc1'),
         ('Hydrogen', '0.17.0'),
         ('Helium', 'Hydrogen'),
         ('v2014.1.4.1-n/a-abcdefgh', 'v2014.1.4.1rc3-n/a-abcdefgh'),
         ('v2014.1.4.1-1-abcdefgh', 'v2014.1.4.1-n/a-abcdefgh')
     )
     for higher_version, lower_version in examples:
         self.assertTrue(SaltStackVersion.parse(higher_version) > lower_version)
         self.assertTrue(SaltStackVersion.parse(lower_version) < higher_version)
开发者ID:DavideyLee,项目名称:salt,代码行数:16,代码来源:version_test.py

示例3: test_version_parsing

# 需要导入模块: from salt.version import SaltStackVersion [as 别名]
# 或者: from salt.version.SaltStackVersion import parse [as 别名]
    def test_version_parsing(self):
        strip_initial_non_numbers_regex = re.compile(r'(?:[^\d]+)?(?P<vs>.*)')
        expect = (
            ('v0.12.0-19-g767d4f9', (0, 12, 0, 0, '', 0, 19, 'g767d4f9'), None),
            ('v0.12.0-85-g2880105', (0, 12, 0, 0, '', 0, 85, 'g2880105'), None),
            ('debian/0.11.1+ds-1-3-ga0afcbd',
             (0, 11, 1, 0, '', 0, 3, 'ga0afcbd'), '0.11.1-3-ga0afcbd'),
            ('0.12.1', (0, 12, 1, 0, '', 0, 0, None), None),
            ('0.12.1', (0, 12, 1, 0, '', 0, 0, None), None),
            ('0.17.0rc1', (0, 17, 0, 0, 'rc', 1, 0, None), None),
            ('v0.17.0rc1-1-g52ebdfd', (0, 17, 0, 0, 'rc', 1, 1, 'g52ebdfd'), None),
            ('v2014.1.4.1', (2014, 1, 4, 1, '', 0, 0, None), None),
            ('v2014.1.4.1rc3-n/a-abcdefgh', (2014, 1, 4, 1, 'rc', 3, -1, 'abcdefgh'), None),
            ('v3.4.1.1', (3, 4, 1, 1, '', 0, 0, None), None)

        )

        for vstr, full_info, version in expect:
            saltstack_version = SaltStackVersion.parse(vstr)
            self.assertEqual(
                saltstack_version.full_info, full_info
            )
            if version is None:
                version = strip_initial_non_numbers_regex.search(vstr).group('vs')
            self.assertEqual(saltstack_version.string, version)
开发者ID:bryson,项目名称:salt,代码行数:27,代码来源:version_test.py

示例4: test_salt_with_git_version

# 需要导入模块: from salt.version import SaltStackVersion [as 别名]
# 或者: from salt.version.SaltStackVersion import parse [as 别名]
    def test_salt_with_git_version(self):
        if getattr(self, '_call_binary_', None) is None:
            self.skipTest('\'_call_binary_\' not defined.')
        from salt.utils import which
        from salt.version import __version_info__, SaltStackVersion
        git = which('git')
        if not git:
            self.skipTest('The git binary is not available')

        # Let's get the output of git describe
        process = subprocess.Popen(
            [git, 'describe', '--tags', '--match', 'v[0-9]*'],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            close_fds=True,
            cwd=CODE_DIR
        )
        out, err = process.communicate()
        if not out:
            self.skipTest(
                'Failed to get the output of \'git describe\'. '
                'Error: {0!r}'.format(
                    err
                )
            )

        parsed_version = SaltStackVersion.parse(out)

        if parsed_version.info < __version_info__:
            self.skipTest(
                'We\'re likely about to release a new version. This test '
                'would fail. Parsed({0!r}) < Expected({1!r})'.format(
                    parsed_version.info, __version_info__
                )
            )
        elif parsed_version.info != __version_info__:
            self.skipTest(
                'In order to get the proper salt version with the '
                'git hash you need to update salt\'s local git '
                'tags. Something like: \'git fetch --tags\' or '
                '\'git fetch --tags upstream\' if you followed '
                'salt\'s contribute documentation. The version '
                'string WILL NOT include the git hash.'
            )
        out = '\n'.join(self.run_script(self._call_binary_, '--version'))
        self.assertIn(parsed_version.string, out)
开发者ID:bemehow,项目名称:salt,代码行数:48,代码来源:__init__.py

示例5: test_unparsable_version

# 需要导入模块: from salt.version import SaltStackVersion [as 别名]
# 或者: from salt.version.SaltStackVersion import parse [as 别名]
    def test_unparsable_version(self):
        with self.assertRaises(ValueError):
            SaltStackVersion.from_name('Drunk')

        with self.assertRaises(ValueError):
            SaltStackVersion.parse('Drunk')
开发者ID:bryson,项目名称:salt,代码行数:8,代码来源:version_test.py

示例6: __get_version

# 需要导入模块: from salt.version import SaltStackVersion [as 别名]
# 或者: from salt.version.SaltStackVersion import parse [as 别名]
def __get_version(version, version_info):
    '''
    If we can get a version provided at installation time or from Git, use
    that instead, otherwise we carry on.
    '''
    try:
        # Try to import the version information provided at install time
        from saltfuse._version import __version__, __version_info__  # pylint: disable=E0611
        return __version__, __version_info__
    except ImportError:
        pass

    # This might be a 'python setup.py develop' installation type. Let's
    # discover the version information at runtime.
    import os
    import warnings
    import subprocess

    if 'SETUP_DIRNAME' in globals():
        # This is from the exec() call in Salt Fuse's setup.py
        cwd = SETUP_DIRNAME  # pylint: disable=E0602
        if not os.path.exists(os.path.join(cwd, '.git')):
            # This is not a Salt Fuse git checkout!!! Don't even try to parse...
            return version, version_info
    else:
        cwd = os.path.abspath(os.path.dirname(__file__))
        if not os.path.exists(os.path.join(os.path.dirname(cwd), '.git')):
            # This is not a Salt git checkout!!! Don't even try to parse...
            return version, version_info

    try:
        kwargs = dict(
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            cwd=cwd
        )

        if not sys.platform.startswith('win'):
            # Let's not import `salt.utils` for the above check
            kwargs['close_fds'] = True

        process = subprocess.Popen(
                ['git', 'describe', '--tags', '--match', 'v[0-9]*'], **kwargs)
        out, err = process.communicate()
        out = out.strip()
        err = err.strip()

        if not out or err:
            return version, version_info

        parsed_version = SaltStackVersion.parse(out)

        if parsed_version.info > version_info:
            warnings.warn(
                'The parsed version info, `{0}`, is bigger than the one '
                'defined in the file, `{1}`. Missing version bump?'.format(
                    parsed_version.info,
                    version_info
                ),
                UserWarning,
                stacklevel=2
            )
            return version, version_info
        elif parsed_version.info < version_info:
            warnings.warn(
                'The parsed version info, `{0}`, is lower than the one '
                'defined in the file, `{1}`.'
                'In order to get the proper salt version with the git hash '
                'you need to update salt\'s local git tags. Something like: '
                '\'git fetch --tags\' or \'git fetch --tags upstream\' if '
                'you followed salt\'s contribute documentation. The version '
                'string WILL NOT include the git hash.'.format(
                    parsed_version.info,
                    version_info
                ),
                UserWarning,
                stacklevel=2
            )
            return version, version_info
        return parsed_version.string, parsed_version.info
    except OSError as os_err:
        if os_err.errno != 2:
            # If the errno is not 2(The system cannot find the file
            # specified), raise the exception so it can be catch by the
            # developers
            raise
    return version, version_info
开发者ID:carriercomm,项目名称:salt-fuse,代码行数:89,代码来源:version.py

示例7: check_bootstrapped_minion_version

# 需要导入模块: from salt.version import SaltStackVersion [as 别名]
# 或者: from salt.version.SaltStackVersion import parse [as 别名]
def check_bootstrapped_minion_version(options):
    '''
    Confirm that the bootstrapped minion version matches the desired one
    '''
    if 'salt_minion_bootstrapped' not in options:
        print_bulleted(options, 'Minion not boostrapped. Not grabbing minion version information.', 'RED')
        sys.exit(1)

    print_bulleted(options, 'Grabbing bootstrapped minion version information ... ')
    cmd = [
        'salt',
        '-t', '100',
        '--out=json',
        '-l', options.log_level
    ]
    if options.no_color:
        cmd.append('--no-color')
    cmd.extend([
        options.vm_name,
        'test.version'
    ])

    stdout, stderr, exitcode = run_command(cmd,
                                           options,
                                           return_output=True,
                                           stream_stdout=False,
                                           stream_stderr=False)
    if exitcode:
        print_bulleted(
            options, 'Failed to get the bootstrapped minion version. Exit code: {0}'.format(exitcode), 'RED'
        )
        sys.exit(exitcode)

    if not stdout.strip():
        print_bulleted(options, 'Failed to get the bootstrapped minion version(no output).', 'RED')
        sys.stdout.flush()
        sys.exit(1)

    try:
        version_info = json.loads(stdout.strip())
        bootstrap_minion_version = os.environ.get(
            'SALT_MINION_BOOTSTRAP_RELEASE',
            options.bootstrap_salt_commit[:7]
        )
        if bootstrap_minion_version.startswith('v'):
            bootstrap_minion_version = bootstrap_minion_version[1:]
        if bootstrap_minion_version not in version_info[options.vm_name]:
            print_bulleted(options, '\n\nATTENTION!!!!\n', 'YELLOW')
            print_bulleted(
                options,
                'The boostrapped minion version commit does not contain the desired commit:',
                'YELLOW'
            )
            print_bulleted(
                options,
                '{0!r} does not contain {1!r}'.format(version_info[options.vm_name], bootstrap_minion_version),
                'YELLOW'
            )
            print('\n\n')
            sys.stdout.flush()
        else:
            print_bulleted(options, 'Matches!', 'LIGHT_GREEN')
        setattr(options, 'bootstrapped_salt_minion_version', SaltStackVersion.parse(version_info[options.vm_name]))
    except (ValueError, TypeError):
        print_bulleted(options, 'Failed to load any JSON from {0!r}'.format(stdout.strip()), 'RED')
开发者ID:rallytime,项目名称:salt-testing,代码行数:67,代码来源:jenkins.py


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