• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python semver.compare函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_version

def get_version():

    from idigbio_media_appliance.version import VERSION
    version = VERSION

    for f in ["package.json", "bower.json"]:
        with io.open(f, "r") as jf:
            config = json.load(jf)

        vs = config["version"]
        if version is None:
            version = vs
        elif semver.compare(vs, version) > 0:
            if options["human"]:
                click.echo("{} had larger version. {} > {}".format(f, vs, version))
            version = vs

    for f in ["meta.yaml", "construct.yaml"]:
        with io.open(f, "r") as yf:
            config = yaml.load(yf)

        if "package" in config:
            vs = config["package"]["version"]
        else:
            vs = config["version"]

        if version is None:
            version = vs
        elif semver.compare(vs, version) > 0:
            if options["human"]:
                click.echo("{} had larger version. {} > {}".format(f, vs, version))
            version = vs

    return version
开发者ID:iDigBio,项目名称:idigbio-media-appliance,代码行数:34,代码来源:versioning.py


示例2: info

 def info(self):
     sess = model.get_session(self.args['db'])
     db_version = sess.query(model.Config).filter(model.Config.name == "version").one().value
     print("Database version %s".format(db_version))
     print("Software version %s".format(__version__))
     if semver.compare(db_version, __version__) == -1:
         self.l.info("Database older than software. Consider updating.")
     elif semver.compare(db_version, __version__) == 1:
         self.l.info("Database newer than software. Some operations will not be possible.")
开发者ID:hamon-in,项目名称:invoice,代码行数:9,代码来源:commands.py


示例3: test_status

    def test_status(self):
        """
        kibana status metricset test
        """

        env = os.environ.get('TESTING_ENVIRONMENT')

        if env == "2x" or env == "5x":
            # Skip for 5.x and 2.x tests as Kibana endpoint not available
            raise SkipTest

        version = self.get_version()
        if semver.compare(version, "6.4.0") == -1:
            # Skip for Kibana versions < 6.4.0 as Kibana endpoint not available
            raise SkipTest

        self.render_config_template(modules=[{
            "name": "kibana",
            "metricsets": ["status"],
            "hosts": self.get_hosts(),
            "period": "1s"
        }])
        proc = self.start_beat()
        self.wait_until(lambda: self.output_lines() > 0, max_timeout=20)
        proc.check_kill_and_wait()
        self.assert_no_logged_warnings()

        output = self.read_output_json()
        self.assertTrue(len(output) >= 1)
        evt = output[0]
        print evt

        self.assert_fields_are_documented(evt)
开发者ID:elastic,项目名称:beats,代码行数:33,代码来源:test_kibana.py


示例4: _get_version

 def _get_version(self, spec):
     spec = self._parse_spec(spec)
     version = spec['version']
     version_sign = spec['version_sign']
     resource_name = spec['resource_name']
     if version_sign == '==':
         return os.path.join(self.fpath, spec['resource_name'], version)
     found = self.iter_contents(resource_name)
     if version is None:
         sc = semver.compare
         sorted_vers = sorted(found,
                              cmp=lambda a, b: sc(a['version'],
                                                  b['version']),
                              reverse=True)
         if not sorted_vers:
             raise ResourceNotFound(spec)
         version = sorted_vers[0]['version']
     else:
         version = '{}{}'.format(version_sign, version)
         matched = filter(lambda x: semver.match(x['version'], version),
                          found)
         sorted_vers = sorted(matched,
                              cmp=lambda a, b: semver.compare(a['version'],
                                                              b['version']),
                              reverse=True)
         version = next((x['version'] for x in sorted_vers
                         if semver.match(x['version'], version)),
                        None)
     if version is None:
         raise ResourceNotFound(spec)
     return version
开发者ID:pigmej,项目名称:solar,代码行数:31,代码来源:repository.py


示例5: test_dev_tool_export_dashboard_by_id_from_space

    def test_dev_tool_export_dashboard_by_id_from_space(self):
        """
        Test dev-tools/cmd/dashboards exports dashboard from Kibana space
        and removes unsupported characters
        """
        version = self.get_version()
        if semver.compare(version, "6.5.0") == -1:
            # Skip for Kibana versions < 6.5.0 as Kibana Spaces not available
            raise SkipTest

        self.test_load_dashboard_into_space(False)

        path = os.path.normpath(self.beat_path + "/../dev-tools/cmd/dashboards/export_dashboards.go")
        command = path + " -kibana http://" + self.get_kibana_host() + ":" + self.get_kibana_port()
        command = "go run " + command + " -dashboard Metricbeat-system-overview -space-id foo-bar"

        p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        content, err = p.communicate()

        assert p.returncode == 0

        assert os.path.isfile("output.json") is True

        with open('output.json') as f:
            content = f.read()
            assert "Metricbeat-system-overview" in content

        os.remove("output.json")
开发者ID:gshamov,项目名称:beats,代码行数:28,代码来源:test_dashboard.py


示例6: cli

def cli(force):
    """
    Update AerisCloud
    """
    if not force and config.get('github', 'enabled', default=False) == 'true':
        client = Github().gh
        repo = client.repository('aeriscloud', 'aeriscloud')
        latest_release = repo.iter_releases().next()
        latest_version = latest_release.tag_name[1:]

        if semver.compare(version, latest_version) != -1:
            click.secho('AerisCloud is already up to date!', fg='green')
            sys.exit(0)

        click.echo('A new version of AerisCloud is available: %s (%s)' % (
            click.style(latest_version, fg='green', bold=True),
            click.style(latest_release.name, bold=True)
        ))

    # retrieve install script in a tmpfile
    tmp = tempfile.NamedTemporaryFile()
    r = requests.get('https://raw.githubusercontent.com/' +
                     'AerisCloud/AerisCloud/develop/scripts/install.sh')
    if r.status_code != 200:
        fatal('error: update server returned %d (%s)' % (
            r.status_code, r.reason))

    tmp.write(r.content)
    tmp.flush()

    os.environ['INSTALL_DIR'] = aeriscloud_path
    call(['bash', tmp.name])

    tmp.close()
开发者ID:AerisCloud,项目名称:AerisCloud,代码行数:34,代码来源:update.py


示例7: main

def main():
    if len(sys.argv) < 2:
        print('%s <dir to translations>' % sys.argv[0])
        sys.exit(1)
    logging.warning('Scanning files...')
    local = collect_local_info(sys.argv[1])
    logging.warning('Fetching remote data...')
    remote = collect_remote_info()
    for f in local:
        remote_ver = remote.get(f[0])
        if not remote_ver:
            logging.error('Local file %s not found in remote data' % f[0])
        if f[1] == remote_ver:
            continue
        try:
            if semver.compare(f[1], remote_ver) >= 0:
                continue
        except ValueError:
            pass
        download_po(f[0], remote_ver, 'zh_CN', sys.argv[1])
        po_file = po_name.format(pkg=f[0], ver=f[1], lang='zh_CN')
        po_file = os.path.join(sys.argv[1], po_file)
        pot_file = po_name.format(pkg=f[0], ver=remote_ver, lang='zh_CN')
        pot_file = os.path.join(sys.argv[1], pot_file)
        if not subprocess.call(['msgmerge', po_file, pot_file, '-o', pot_file]):
            os.remove(po_file)
开发者ID:AOSC-Dev,项目名称:scriptlets,代码行数:26,代码来源:refresh-tp.py


示例8: show_version

def show_version(action='show', host='eng'):
    """
    prints, gets or checks versions (installed and candidate) from navitia-kraken/navitia-tyr/navitia-jormungandr package
    show: print versions on stdout
    get: returns tuple (installed, candidate) or (None, None) if navitia-kraken/tyr/jormungandr not installed on target,
         installed and candidate can be tuples if different versions are coexisting
    check: return True if candidate version is different from installed
    """
    versions = execute(get_version, host)
    def summarize(iterable):
        s = tuple(set(iterable))
        if len(s) == 1:
            return s[0]
        return s
    if action == 'show':
        print(green(host_app_mapping[host]))
        for k, v in versions.iteritems():
            print(green("  %s, installed: %s, candidate: %s" % (k, v[0], v[1])))
    elif action == 'get':
        installed = summarize(x[0] for x in versions.itervalues())
        candidate = summarize(x[1] for x in versions.itervalues())
        return installed, candidate
    elif action == 'check':
        if env.manual_package_deploy:
            print(yellow("WARNING Can't check versions of manually installed packages"))
            return True
        installed = summarize(x[0] for x in versions.itervalues())
        candidate = summarize(x[1] for x in versions.itervalues())
        if isinstance(installed, tuple):
            installed = max(installed)
        return semver.compare(candidate, installed) > 0
开发者ID:aromatix,项目名称:fabric_navitia,代码行数:31,代码来源:utils.py


示例9: check_version

    def check_version(self, message):
        versionDB, updateFile = self.player_service.client_version_info
        update_msg = dict(command="update",
                          update=updateFile,
                          new_version=versionDB)

        self.user_agent = message.get('user_agent')
        version = message.get('version')
        server.stats.gauge('user.agents.None', -1, delta=True)
        server.stats.gauge('user.agents.{}'.format(self.user_agent), 1, delta=True)

        if not version or not self.user_agent:
            update_msg['command'] = 'welcome'
            # For compatibility with 0.10.x updating mechanism
            self.sendJSON(update_msg)
            return False

        # Check their client is reporting the right version number.
        if 'downlords-faf-client' not in self.user_agent:
            try:
                if "-" in version:
                    version = version.split('-')[0]
                if "+" in version:
                    version = version.split('+')[0]
                if semver.compare(versionDB, version) > 0:
                    self.sendJSON(update_msg)
                    return False
            except ValueError:
                self.sendJSON(update_msg)
                return False
        return True
开发者ID:FAForever,项目名称:server,代码行数:31,代码来源:lobbyconnection.py


示例10: get_latest_version_tag

def get_latest_version_tag():
    try:

        response = urllib2.urlopen("http://archive.fabscan.org/dists/stable/main/binary-armhf/Packages", timeout=5)

        latest_version = __version__
        line = 'START'
        while line != '':
            line = response.readline()
            if PACKAGE_PATTERN.match(line):
                while line != '':
                    line = response.readline()
                    match = VERSION_PATTERN.match(line)
                    if match is not None:
                        package_version = match.group(1)
                        try:
                            if semver.compare(latest_version, package_version) == -1:
                                latest_version = package_version
                        except ValueError:
                            # ignore invalid version number
                            pass
                        break
        return latest_version
    except (Exception, urllib2.URLError) as e:
        _logger.debug(e)
        return "0.0.0"
开发者ID:jenshackel,项目名称:FabScanPi-Server,代码行数:26,代码来源:FSUpdate.py


示例11: test_load_dashboard_into_space

    def test_load_dashboard_into_space(self, create_space=True):
        """
        Test loading dashboards into Kibana space
        """
        version = self.get_version()
        if semver.compare(version, "6.5.0") == -1:
            # Skip for Kibana versions < 6.5.0 as Kibana Spaces not available
            raise SkipTest

        self.render_config_template()
        if create_space:
            self.create_kibana_space()

        beat = self.start_beat(
            logging_args=["-e", "-d", "*"],
            extra_args=["setup",
                        "--dashboards",
                        "-E", "setup.dashboards.file=" +
                        os.path.join(self.beat_path, "tests", "files", "testbeat-dashboards.zip"),
                        "-E", "setup.dashboards.beat=testbeat",
                        "-E", "setup.kibana.protocol=http",
                        "-E", "setup.kibana.host=" + self.get_kibana_host(),
                        "-E", "setup.kibana.port=" + self.get_kibana_port(),
                        "-E", "setup.kibana.space.id=foo-bar",
                        "-E", "output.elasticsearch.hosts=['" + self.get_host() + "']",
                        "-E", "output.file.enabled=false"]
        )

        beat.check_wait(exit_code=0)

        assert self.log_contains("Kibana dashboards successfully loaded") is True
开发者ID:gshamov,项目名称:beats,代码行数:31,代码来源:test_dashboard.py


示例12: check_version

    def check_version(self, message):
        versionDB, updateFile = self.player_service.client_version_info
        update_msg = dict(command="update",
                          update=updateFile,
                          new_version=versionDB)

        if 'version' not in message or 'user_agent' not in message:
            update_msg['command'] = 'welcome'
            # For compatibility with 0.10.x updating mechanism
            self.sendJSON(update_msg)
            return False

        version = message.get('version')

        # Check their client is reporting the right version number.
        if message.get('user_agent', None) != 'downlords-faf-client':
            try:
                if "-" in version:
                    version = version.split('-')[0]
                if "+" in version:
                    version = version.split('+')[0]
                if semver.compare(versionDB, version) > 0:
                    self.sendJSON(update_msg)
                    return False
            except ValueError:
                self.sendJSON(update_msg)
                return False
        return True
开发者ID:yorick-ne,项目名称:server,代码行数:28,代码来源:lobbyconnection.py


示例13: tags

 def tags(self):
     """
         :returns: list of git tags, sorted by the version number.
     """
     cmd = 'git tag'
     tags = self.sh(cmd, True).split('\n')
     compare = lambda x, y: semver.compare(x.lstrip('v'), y.lstrip('v'))
     return sorted(tags, key=cmp_to_key(compare))
开发者ID:reubano,项目名称:ongeza,代码行数:8,代码来源:git_utils.py


示例14: test_should_follow_specification_comparison

 def test_should_follow_specification_comparison(self):
     # produce comparsion chain:
     # 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-beta.2 < 1.0.0-beta.11
     # < 1.0.0-rc.1 < 1.0.0-rc.1+build.1 < 1.0.0 < 1.0.0+0.3.7 < 1.3.7+build
     # < 1.3.7+build.2.b8f12d7 < 1.3.7+build.11.e0f985a
     # and in backward too.
     chain = ['1.0.0-alpha', '1.0.0-alpha.1', '1.0.0-beta.2',
              '1.0.0-beta.11', '1.0.0-rc.1',
              '1.0.0', '1.3.7+build']
     versions = zip(chain[:-1], chain[1:])
     for low_version, high_version in versions:
         self.assertEqual(
             compare(low_version, high_version), -1,
             '%s should be lesser than %s' % (low_version, high_version))
         self.assertEqual(
             compare(high_version, low_version), 1,
             '%s should be higher than %s' % (high_version, low_version))
开发者ID:chinakids,项目名称:python-semver,代码行数:17,代码来源:semver_test.py


示例15: check_skip

    def check_skip(self, metricset, es):
        if metricset != "ccr":
            return

        version = self.get_version(es)
        if semver.compare(version, "6.5.0") == -1:
            # Skip CCR metricset system test for Elasticsearch versions < 6.5.0 as CCR Stats
            # API endpoint is not available
            raise SkipTest("elasticsearch/ccr metricset system test only valid with Elasticsearch versions >= 6.5.0")
开发者ID:7AC,项目名称:beats,代码行数:9,代码来源:test_elasticsearch.py


示例16: _can_upgrade

    def _can_upgrade(self, device, device_version):
        if device.platform != 'electron':
            return True

        if not device_version or semver.compare(device_version, '0.5.3') < 0:
            self.electron_upgrade_popup.open()
            return False

        return True
开发者ID:spark,项目名称:device-updater,代码行数:9,代码来源:gui.py


示例17: _compare_and_update

def _compare_and_update(latest_version):
    # TODO: support alpha channel (allow setting which channel to check & parse build number)
    is_newer = semver.compare(current_version, latest_version) == -1
    logging.info("Latest version: %s (newer: %s)", latest_version, is_newer)

    if is_newer:
        redis_connection.set(REDIS_KEY, latest_version)
    else:
        redis_connection.delete(REDIS_KEY)
开发者ID:13768324554,项目名称:redash,代码行数:9,代码来源:version_check.py


示例18: test_should_follow_specification_comparison

def test_should_follow_specification_comparison():
    """
    produce comparison chain:
    1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-beta.2 < 1.0.0-beta.11
    < 1.0.0-rc.1 < 1.0.0-rc.1+build.1 < 1.0.0 < 1.0.0+0.3.7 < 1.3.7+build
    < 1.3.7+build.2.b8f12d7 < 1.3.7+build.11.e0f985a
    and in backward too.
    """
    chain = [
        '1.0.0-alpha', '1.0.0-alpha.1', '1.0.0-beta.2', '1.0.0-beta.11',
        '1.0.0-rc.1', '1.0.0', '1.3.7+build',
    ]
    versions = zip(chain[:-1], chain[1:])
    for low_version, high_version in versions:
        assert compare(low_version, high_version) == -1, \
            '%s should be lesser than %s' % (low_version, high_version)
        assert compare(high_version, low_version) == 1,  \
            '%s should be higher than %s' % (high_version, low_version)
开发者ID:jeloagnasin,项目名称:python-semver,代码行数:18,代码来源:tests.py


示例19: update

 def update(self):
     sess = model.get_session(self.args['db'])
     db_version = sess.query(model.Config).filter(model.Config.name == "version").one().value
     sw_version = __version__
     alembic_cfg = helpers.get_alembic_config(self.args['db'])
     
     self.l.debug("Software version %s", sw_version)
     self.l.debug("Database version %s", db_version)
     if semver.compare(db_version, sw_version) == -1:
         command.upgrade(alembic_cfg, "head")
         version = sess.query(model.Config).filter(model.Config.name == "version").one()
         version.value = __version__
         sess.add(version)
         sess.commit()
         self.l.info("Database older than software. Updated to %s", __version__)
     elif semver.compare(db_version, __version__) == 1:
         self.l.info("Database newer than software. Please upgrade the application.")
     else:
         self.l.info("No updates necessary.")
开发者ID:hamon-in,项目名称:invoice,代码行数:19,代码来源:commands.py


示例20: test_should_raise_value_error_for_invalid_value

def test_should_raise_value_error_for_invalid_value():
    with pytest.raises(ValueError):
        compare('foo', 'bar')
    with pytest.raises(ValueError):
        compare('1.0', '1.0.0')
    with pytest.raises(ValueError):
        compare('1.x', '1.0.0')
开发者ID:jeloagnasin,项目名称:python-semver,代码行数:7,代码来源:tests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python semver.match函数代码示例发布时间:2022-05-27
下一篇:
Python dates.DateService类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap