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


Python Test.cache_key方法代码示例

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


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

示例1: get

# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import cache_key [as 别名]
    def get(self):
        self.response.headers['Content-Type'] = 'application/json'

        test_id, branch_id, platform_id = _get_test_branch_platform_ids(self)
        runs = PersistentCache.get_cache(Test.cache_key(test_id, branch_id, platform_id))
        if runs:
            self.response.out.write(runs)
        else:
            schedule_runs_update(test_id, branch_id, platform_id)
开发者ID:,项目名称:,代码行数:11,代码来源:

示例2: post

# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import cache_key [as 别名]
    def post(self):
        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
        test_id, branch_id, platform_id = _get_test_branch_platform_ids(self)

        branch = model_from_numeric_id(branch_id, Branch)
        platform = model_from_numeric_id(platform_id, Platform)
        test = model_from_numeric_id(test_id, Test)
        assert branch
        assert platform
        assert test

        PersistentCache.set_cache(Test.cache_key(test_id, branch_id, platform_id), Runs(branch, platform, test.name).to_json())
        self.response.out.write('OK')
开发者ID:,项目名称:,代码行数:15,代码来源:

示例3: post

# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import cache_key [as 别名]
    def post(self):
        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'

        headers = "\n".join([key + ': ' + value for key, value in self.request.headers.items()])

        # Do as best as we can to remove the password
        request_body_without_password = re.sub(r'"password"\s*:\s*".+?",', '', self.request.body)
        log = ReportLog(timestamp=datetime.now(), headers=headers, payload=request_body_without_password)
        log.put()

        try:
            self._body = json.loads(self.request.body)
        except ValueError:
            return self._output('Failed to parse the payload as a json. Report key: %d' % log.key().id())

        builder = self._model_by_key_name_in_body_or_error(Builder, 'builder-name')
        branch = self._model_by_key_name_in_body_or_error(Branch, 'branch')
        platform = self._model_by_key_name_in_body_or_error(Platform, 'platform')
        build_number = self._integer_in_body('build-number')
        timestamp = self._timestamp_in_body()
        revision = self._integer_in_body('webkit-revision')
        chromium_revision = self._integer_in_body('webkit-revision') if 'chromium-revision' in self._body else None

        failed = False
        if builder and not (self.bypass_authentication() or builder.authenticate(self._body.get('password', ''))):
            self._output('Authentication failed')
            failed = True

        if not self._results_are_valid():
            self._output("The payload doesn't contain results or results are malformed")
            failed = True

        if not (builder and branch and platform and build_number and revision and timestamp) or failed:
            return

        build = self._create_build_if_possible(builder, build_number, branch, platform, timestamp, revision, chromium_revision)
        if not build:
            return

        def _float_or_none(dictionary, key):
            value = dictionary.get(key)
            if value:
                return float(value)
            return None

        for test_name, result in self._body['results'].iteritems():
            test = self._add_test_if_needed(test_name, branch, platform)
            memcache.delete(Test.cache_key(test.id, branch.id, platform.id))
            if isinstance(result, dict):
                TestResult(name=test_name, build=build, value=float(result['avg']), valueMedian=_float_or_none(result, 'median'),
                    valueStdev=_float_or_none(result, 'stdev'), valueMin=_float_or_none(result, 'min'), valueMax=_float_or_none(result, 'max')).put()
            else:
                TestResult(name=test_name, build=build, value=float(result)).put()

        log = ReportLog.get(log.key())
        log.delete()

        # We need to update dashboard and manifest because they are affected by the existance of test results
        memcache.delete('dashboard')
        memcache.delete('manifest')

        return self._output('OK')
开发者ID:sohocoke,项目名称:webkit,代码行数:64,代码来源:report_handler.py

示例4: get

# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import cache_key [as 别名]
    def get(self):
        self.response.headers['Content-Type'] = 'application/json; charset=utf-8'

        try:
            test_id = int(self.request.get('id', 0))
            branch_id = int(self.request.get('branchid', 0))
            platform_id = int(self.request.get('platformid', 0))
        except TypeError:
            # FIXME: Output an error here
            test_id = 0
            branch_id = 0
            platform_id = 0

        # FIXME: Just fetch builds specified by "days"
        # days = self.request.get('days', 365)

        cache_key = Test.cache_key(test_id, branch_id, platform_id)
        cache = memcache.get(cache_key)
        if cache:
            self.response.out.write(cache)
            return

        builds = Build.all()
        builds.filter('branch =', modelFromNumericId(branch_id, Branch))
        builds.filter('platform =', modelFromNumericId(platform_id, Platform))

        test = modelFromNumericId(test_id, Test)
        test_name = test.name if test else None
        test_runs = []
        averages = {}
        values = []
        timestamps = []

        for build in builds:
            results = TestResult.all()
            results.filter('name =', test_name)
            results.filter('build =', build)
            for result in results:
                builderId = build.builder.key().id()
                posixTimestamp = mktime(build.timestamp.timetuple())
                statistics = None
                if result.valueStdev != None and result.valueMin != None and result.valueMax != None:
                    statistics = {'stdev': result.valueStdev, 'min': result.valueMin, 'max': result.valueMax}
                test_runs.append([result.key().id(),
                    [build.key().id(), build.buildNumber, build.revision],
                    posixTimestamp, result.value, 0,  # runNumber
                    [],  # annotations
                    builderId, statistics])
                # FIXME: Calculate the average; in practice, we wouldn't have more than one value for a given revision
                averages[build.revision] = result.value
                values.append(result.value)
                timestamps.append(posixTimestamp)

        result = json.dumps({
            'test_runs': test_runs,
            'averages': averages,
            'min': min(values) if values else None,
            'max': max(values) if values else None,
            'date_range': [min(timestamps), max(timestamps)] if timestamps else None,
            'stat': 'ok'})
        self.response.out.write(result)
        memcache.add(cache_key, result)
开发者ID:sohocoke,项目名称:webkit,代码行数:64,代码来源:runs_handler.py

示例5: cache_runs

# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import cache_key [as 别名]
def cache_runs(test_id, branch_id, platform_id, cache):
    PersistentCache.set_cache(Test.cache_key(test_id, branch_id, platform_id), cache)
开发者ID:,项目名称:,代码行数:4,代码来源:


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