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


Python semver.compare函数代码示例

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


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


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