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


Python compare.vint函数代码示例

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


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

示例1: test_appver_long

    def test_appver_long(self):
        too_big = vnum(vint(MAXVERSION + 1))
        just_right = vnum(vint(MAXVERSION))

        assert self.check_appver_filters(too_big, floor_version(just_right)), "All I ask is do not crash"

        eq_(
            self.check_appver_filters("9999999", "9999999.0"),
            [
                {"text": u"Firefox 9999999.0", "selected": True, "urlparams": {"appver": "9999999.0"}, "children": []},
                {"text": u"Firefox 5.0", "selected": False, "urlparams": {"appver": "5.0"}, "children": []},
            ],
        )

        eq_(
            self.check_appver_filters("99999999", "99999999.0"),
            [
                {
                    "text": u"Firefox 99999999.0",
                    "selected": True,
                    "urlparams": {"appver": "99999999.0"},
                    "children": [],
                },
                {"text": u"Firefox 5.0", "selected": False, "urlparams": {"appver": "5.0"}, "children": []},
            ],
        )
开发者ID:robhudson,项目名称:olympia,代码行数:26,代码来源:test_views.py

示例2: find_jetpacks

def find_jetpacks(minver, maxver):
    """
    Find all jetpack files that aren't disabled.

    Files that should be upgraded will have needs_upgrade=True.
    """
    from .models import File
    statuses = amo.VALID_STATUSES
    files = (File.objects.filter(jetpack_version__isnull=False,
                                 version__addon__auto_repackage=True,
                                 version__addon__status__in=statuses,
                                 version__addon__disabled_by_user=False)
             .exclude(status=amo.STATUS_DISABLED).no_cache()
             .select_related('version'))
    files = sorted(files, key=lambda f: (f.version.addon_id, f.version.id))

    # Figure out which files need to be upgraded.
    for file_ in files:
        file_.needs_upgrade = False
    # If any files for this add-on are reviewed, take the last reviewed file
    # plus all newer files.  Otherwise, only upgrade the latest file.
    for _group, fs in groupby(files, key=lambda f: f.version.addon_id):
        fs = list(fs)
        if any(f.status in amo.REVIEWED_STATUSES for f in fs):
            for file_ in reversed(fs):
                file_.needs_upgrade = True
                if file_.status in amo.REVIEWED_STATUSES:
                    break
        else:
            fs[-1].needs_upgrade = True
    # Make sure only old files are marked.
    for file_ in [f for f in files if f.needs_upgrade]:
        if not (vint(minver) <= vint(file_.jetpack_version) < vint(maxver)):
            file_.needs_upgrade = False
    return files
开发者ID:ujdhesa,项目名称:olympia,代码行数:35,代码来源:utils.py

示例3: test_appver_long

    def test_appver_long(self):
        too_big = vnum(vint(MAXVERSION + 1))
        just_right = vnum(vint(MAXVERSION))

        assert self.check_appver_filters(too_big, floor_version(just_right)), (
            'All I ask is do not crash')

        eq_(self.check_appver_filters('9999999', '9999999.0'),
            [{'text': u'Firefox 9999999.0',
              'selected': True,
              'urlparams': {'appver': '9999999.0'},
              'children': []},
             {'text': u'Firefox 5.0',
              'selected': False,
              'urlparams': {'appver': '5.0'},
              'children': []}])

        eq_(self.check_appver_filters('99999999', '99999999.0'),
            [{'text': u'Firefox 99999999.0',
              'selected': True,
              'urlparams': {'appver': '99999999.0'},
              'children': []},
             {'text': u'Firefox 5.0',
              'selected': False,
              'urlparams': {'appver': '5.0'},
              'children': []}])
开发者ID:AALEKH,项目名称:zamboni,代码行数:26,代码来源:test_views.py

示例4: check_jetpack_version

def check_jetpack_version(sender, **kw):
    import files.tasks
    from files.utils import JetpackUpgrader

    minver, maxver = JetpackUpgrader().jetpack_versions()
    qs = File.objects.filter(version__addon=sender, jetpack_version__isnull=False)
    ids = [f.id for f in qs if vint(minver) <= vint(f.jetpack_version) < vint(maxver)]
    if ids:
        files.tasks.start_upgrade.delay(ids, priority="high")
开发者ID:chetanmelkani,项目名称:olympia,代码行数:9,代码来源:models.py

示例5: version_compat

def version_compat(qs, compat, app):
    facets = []
    for v, prev in zip(compat['versions'], (None,) + compat['versions']):
        d = {'from': vint(v)}
        if prev:
            d['to'] = vint(prev)
        facets.append(d)
    qs = qs.facet(by_status={'range': {'support.%s.max' % app: facets}})
    result = qs[:0].raw()
    total_addons = result['hits']['total']
    ranges = result['facets']['by_status']['ranges']
    faceted = [(v, r['count']) for v, r in zip(compat['versions'], ranges)]
    other = total_addons - sum(r[1] for r in faceted)
    return total_addons, faceted + [(_('Other'), other)]
开发者ID:frankk00,项目名称:zamboni,代码行数:14,代码来源:views.py

示例6: compat_stats

def compat_stats(request, app, ver, ratio, binary):
    # Get the list of add-ons for usage stats.
    redis = redisutils.connections["master"]
    # Show add-ons marked as incompatible with this current version having
    # greater than 10 incompatible reports and whose average exceeds 80%.
    ver_int = str(vint(ver))
    prefix = "works.%s.%s" % (app, ver_int)
    qs = (
        AppCompat.search()
        .filter(
            **{"%s.failure__gt" % prefix: 10, "%s.failure_ratio__gt" % prefix: ratio, "support.%s.max__gte" % app: 0}
        )
        .order_by("-%s.failure_ratio" % prefix, "-%s.total" % prefix)
        .values_dict()
    )
    if binary is not None:
        qs = qs.filter(binary=binary)
    addons = amo.utils.paginate(request, qs)
    for obj in addons.object_list:
        obj["usage"] = obj["usage"][app]
        obj["max_version"] = obj["max_version"][app]
        obj["works"] = obj["works"][app].get(ver_int, {})
        # Get all overrides for this add-on.
        obj["overrides"] = CompatOverride.objects.filter(addon__id=obj["id"])
        # Determine if there is an override for this current app version.
        obj["has_override"] = obj["overrides"].filter(_compat_ranges__min_app_version=ver + "a1").exists()
    total = int(redis.hget("compat:%s" % app, "total"))
    return addons, total
开发者ID:pennyfx,项目名称:zamboni,代码行数:28,代码来源:views.py

示例7: compat_stats

def compat_stats(request, app, ver, minimum, ratio, binary):
    # Get the list of add-ons for usage stats.
    # Show add-ons marked as incompatible with this current version having
    # greater than 10 incompatible reports and whose average exceeds 80%.
    ver_int = str(vint(ver))
    prefix = 'works.%s.%s' % (app, ver_int)
    qs = (AppCompat.search()
          .filter(**{'%s.failure__gt' % prefix: minimum,
                     '%s.failure_ratio__gt' % prefix: ratio,
                     'support.%s.max__gte' % app: 0})
          .order_by('-%s.failure_ratio' % prefix,
                    '-%s.total' % prefix)
          .values_dict())
    if binary is not None:
        qs = qs.filter(binary=binary)
    addons = amo.utils.paginate(request, qs)
    for obj in addons.object_list:
        obj['usage'] = obj['usage'][app]
        obj['max_version'] = obj['max_version'][app]
        obj['works'] = obj['works'][app].get(ver_int, {})
        # Get all overrides for this add-on.
        obj['overrides'] = CompatOverride.objects.filter(addon__id=obj['id'])
        # Determine if there is an override for this current app version.
        obj['has_override'] = obj['overrides'].filter(
            _compat_ranges__min_app_version=ver + 'a1').exists()
    return addons, CompatTotals.objects.get(app=app).total
开发者ID:darkwing,项目名称:zamboni,代码行数:26,代码来源:views.py

示例8: start_upgrade

def start_upgrade(file_ids, sdk_version=None, priority='low', **kw):
    upgrader = JetpackUpgrader()
    minver, maxver = upgrader.jetpack_versions()
    files = File.objects.filter(id__in=file_ids).select_related('version')
    now = datetime.now()
    filedata = {}
    for file_ in files:
        if not (file_.jetpack_version and
                vint(minver) <= vint(file_.jetpack_version) < vint(maxver)):
            continue

        jp_log.info('Sending %s to builder for jetpack version %s.'
                    % (file_.id, maxver))
        # Data stored locally so we can figure out job details and if it should
        # be cancelled.
        data = {'file': file_.id,
                'version': maxver,
                'time': now,
                'uuid': uuid.uuid4().hex,
                'status': 'Sent to builder',
                'owner': 'bulk'}

        # Data POSTed to the builder.
        post = {'addon': file_.version.addon_id,
                'file_id': file_.id,
                'priority': priority,
                'secret': settings.BUILDER_SECRET_KEY,
                'uuid': data['uuid'],
                'pingback': absolutify(reverse('amo.builder-pingback'))}
        if file_.builder_version:
            post['package_key'] = file_.builder_version
        else:
            # Older jetpacks might not have builderVersion in their harness.
            post['location'] = file_.get_url_path('builder')
        if sdk_version:
            post['sdk_version'] = sdk_version
        try:
            jp_log.info(urllib.urlencode(post))
            response = urllib2.urlopen(settings.BUILDER_UPGRADE_URL,
                                       urllib.urlencode(post))
            jp_log.info('Response from builder for %s: [%s] %s' %
                         (file_.id, response.code, response.read()))
        except Exception:
            jp_log.error('Could not talk to builder for %s.' % file_.id,
                         exc_info=True)
        filedata[file_.id] = data
    upgrader.files(filedata)
开发者ID:abev66,项目名称:zamboni,代码行数:47,代码来源:tasks.py

示例9: start_upgrade

def start_upgrade(file_ids, sdk_version=None, priority="low", **kw):
    upgrader = JetpackUpgrader()
    minver, maxver = upgrader.jetpack_versions()
    files = File.objects.filter(id__in=file_ids).select_related("version")
    now = datetime.now()
    filedata = {}
    for file_ in files:
        if not (file_.jetpack_version and vint(minver) <= vint(file_.jetpack_version) < vint(maxver)):
            continue

        jp_log.info("Sending %s to builder for jetpack version %s." % (file_.id, maxver))
        # Data stored locally so we can figure out job details and if it should
        # be cancelled.
        data = {
            "file": file_.id,
            "version": maxver,
            "time": now,
            "uuid": uuid.uuid4().hex,
            "status": "Sent to builder",
            "owner": "bulk",
        }

        # Data POSTed to the builder.
        post = {
            "addon": file_.version.addon_id,
            "file_id": file_.id,
            "priority": priority,
            "secret": settings.BUILDER_SECRET_KEY,
            "uuid": data["uuid"],
            "pingback": absolutify(reverse("amo.builder-pingback")),
        }
        if file_.builder_version:
            post["package_key"] = file_.builder_version
        else:
            # Older jetpacks might not have builderVersion in their harness.
            post["location"] = file_.get_url_path("builder")
        if sdk_version:
            post["sdk_version"] = sdk_version
        try:
            jp_log.info(urllib.urlencode(post))
            response = urllib2.urlopen(settings.BUILDER_UPGRADE_URL, urllib.urlencode(post))
            jp_log.info("Response from builder for %s: [%s] %s" % (file_.id, response.code, response.read()))
        except Exception:
            jp_log.error("Could not talk to builder for %s." % file_.id, exc_info=True)
        filedata[file_.id] = data
    upgrader.files(filedata)
开发者ID:abhiii5459,项目名称:olympia,代码行数:46,代码来源:tasks.py

示例10: index

def index(request, version=None):
    template = 'compat/index.html'
    COMPAT = [v for v in amo.COMPAT if v['app'] == request.APP.id]
    compat_dict = dict((v['main'], v) for v in COMPAT)
    if not COMPAT:
        return jingo.render(request, template, {'results': False})
    if version not in compat_dict:
        return http.HttpResponseRedirect(reverse('compat.index',
                                                 args=[COMPAT[0]['main']]))
    qs = AppCompat.search()
    binary = None

    initial = {'appver': '%s-%s' % (request.APP.id, version), 'type': 'all'}
    initial.update(request.GET.items())
    form = CompatForm(initial)
    if request.GET and form.is_valid():
        if form.cleaned_data['appver']:
            app, ver = form.cleaned_data['appver'].split('-')
            if int(app) != request.APP.id or ver != version:
                new = reverse('compat.index', args=[ver], add_prefix=False)
                url = '/%s%s' % (amo.APP_IDS[int(app)].short, new)
                type_ = form.cleaned_data['type'] or None
                return http.HttpResponseRedirect(urlparams(url, type=type_))

        if form.cleaned_data['type'] != 'all':
            binary = form.cleaned_data['type'] == 'binary'

    compat, app = compat_dict[version], str(request.APP.id)
    compat_queries = (
        ('prev', qs.query(**{
            'top_95.%s.%s' % (app, vint(compat['previous'])): True,
            'support.%s.max__gte' % app: vint(compat['previous'])})),
        ('top_95', qs.query(**{'top_95_all.%s' % app: True})),
        ('all', qs),
    )
    compat_levels = [(key, version_compat(qs, compat, app, binary))
                     for key, qs in compat_queries]
    usage_addons, usage_total = usage_stats(request, compat, app, binary)
    return jingo.render(request, template,
                        {'version': version,
                         'usage_addons': usage_addons,
                         'usage_total': usage_total,
                         'compat_levels': compat_levels,
                         'form': form,
                         'results': True,
                         'show_previous': request.GET.get('previous')})
开发者ID:vinu76jsr,项目名称:zamboni,代码行数:46,代码来源:views.py

示例11: version_compat

def version_compat(qs, compat, app, binary):
    facets = []
    for v, prev in zip(compat['versions'], (None,) + compat['versions']):
        d = {'from': vint(v)}
        if prev:
            d['to'] = vint(prev)
        facets.append(d)
    # Pick up everything else for an Other count.
    facets.append({'to': vint(compat['versions'][-1])})
    facet = {'range': {'support.%s.max' % app: facets}}
    if binary is not None:
        qs = qs.query(binary=binary)
    qs = qs.facet(by_status=facet)
    result = qs[:0].raw()
    total_addons = result['hits']['total']
    ranges = result['facets']['by_status']['ranges']
    titles = compat['versions'] + (_('Other'),)
    faceted = [(v, r['count']) for v, r in zip(titles, ranges)]
    return total_addons, faceted
开发者ID:brijmohan,项目名称:zamboni,代码行数:19,代码来源:views.py

示例12: usage_stats

def usage_stats(request, compat, app):
    # Get the list of add-ons for usage stats.
    redis = redisutils.connections['master']
    qs = (AppCompat.search().order_by('-usage.%s' % app).values_dict()
          .filter(**{'support.%s.max__gte' % app: vint(compat['previous'])}))
    addons = amo.utils.paginate(request, qs)
    for obj in addons.object_list:
        obj['usage'] = obj['usage'][app]
        obj['max_version'] = obj['max_version'][app]
    total = int(redis.hget('compat:%s' % app, 'total'))
    return addons, total
开发者ID:frankk00,项目名称:zamboni,代码行数:11,代码来源:views.py

示例13: usage_stats

def usage_stats(request, compat, app, binary=None):
    # Get the list of add-ons for usage stats.
    qs = AppCompat.search().order_by('-usage.%s' % app).values_dict()
    if request.GET.get('previous'):
        qs = qs.filter(**{
            'support.%s.max__gte' % app: vint(compat['previous'])})
    else:
        qs = qs.filter(**{'support.%s.max__gte' % app: 0})
    if binary is not None:
        qs = qs.filter(binary=binary)
    addons = amo.utils.paginate(request, qs)
    for obj in addons.object_list:
        obj['usage'] = obj['usage'][app]
        obj['max_version'] = obj['max_version'][app]
    return addons, CompatTotals.objects.get(app=app).total
开发者ID:jvillalobos,项目名称:olympia,代码行数:15,代码来源:views.py

示例14: index

def index(request, version=None):
    COMPAT = [v for v in settings.COMPAT if v['app'] == request.APP.id]
    compat_dict = dict((v['main'], v) for v in COMPAT)
    if not COMPAT:
        raise http.Http404()
    if version not in compat_dict:
        return redirect('compat.index', COMPAT[0]['main'])

    compat, app = compat_dict[version], str(request.APP.id)
    qs = AppCompat.search()
    compat_queries = (
        ('prev', qs.query(top_95=True, **{
            'support.%s.max__gte' % app: vint(compat['previous'])})),
        ('top_95', qs.query(top_95=True)),
        ('all', qs),
    )
    compat_levels = [(key, version_compat(qs, compat, app))
                     for key, qs in compat_queries]
    usage_addons, usage_total = usage_stats(request, compat, app)
    return jingo.render(request, 'compat/index.html',
                        {'version': version,
                         'usage_addons': usage_addons,
                         'usage_total': usage_total,
                         'compat_levels': compat_levels})
开发者ID:frankk00,项目名称:zamboni,代码行数:24,代码来源:views.py

示例15: matches_user_agent

 def matches_user_agent(cls, user_agent):
     for user_agent_re in cls.user_agent_re:
         match = user_agent_re.search(user_agent)
         if match:
             v = match.groups()[0]
             return vint(cls.min_display_version) <= vint(v)
开发者ID:caseybecking,项目名称:zamboni,代码行数:6,代码来源:applications.py


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