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


Python models.Platform类代码示例

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


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

示例1: execute

 def execute(id):
     if Platform.get_by_key_name(key):
         error[0] = 'Platform "%s" already exists' % key
         return
     platform = Platform(id=id, name=name, key_name=key)
     platform.put()
     return platform
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: __init__

    def __init__(self):
        # FIXME: This function is massive. Break it up
        self._test_map = {}
        platform_id_map = {}
        branch_id_map = {}
        for test in Test.all():
            if test.hidden:
                continue

            branch_ids = [Branch.get(branch_key).id for branch_key in test.branches]
            platform_ids = [Platform.get(platform_key).id for platform_key in test.platforms]
            self._test_map[test.id] = {
                'name': test.name,
                'branchIds': branch_ids,
                'platformIds': platform_ids,
            }

            for platform_id in platform_ids:
                platform_id_map.setdefault(platform_id, {'tests': [], 'branches': []})
                platform_id_map[platform_id]['tests'].append(test.id)
                platform_id_map[platform_id]['branches'] += branch_ids

            for branch_id in branch_ids:
                branch_id_map.setdefault(branch_id, {'tests': [], 'platforms': []})
                branch_id_map[branch_id]['tests'].append(test.id)
                branch_id_map[branch_id]['platforms'] += platform_ids

        self._platform_map = {}
        for platform in Platform.all():
            if platform.id not in platform_id_map:
                continue

            if platform.hidden:
                for test_id in platform_id_map[platform.id]['tests']:
                    self._test_map[test_id]['platformIds'].remove(platform.id)
                for branch_id in platform_id_map[platform.id]['branches']:
                    branch_id_map[branch_id]['platforms'].remove(platform.id)
                continue

            self._platform_map[platform.id] = {
                'name': platform.name,
                'testIds': list(set(platform_id_map[platform.id]['tests'])),
                'branchIds': list(set(platform_id_map[platform.id]['branches'])),
            }

        self._branch_map = {}
        for branch in Branch.all():
            if branch.id not in branch_id_map:
                continue
            self._branch_map[branch.id] = {
                'name': branch.name,
                'testIds': list(set(branch_id_map[branch.id]['tests'])),
                'platformIds': list(set(branch_id_map[branch.id]['platforms'])),
            }
开发者ID:EQ4,项目名称:h5vcc,代码行数:54,代码来源:json_generators.py

示例3: test_value_two_platforms

 def test_value_two_platforms(self):
     webkit_trunk = Branch.create_if_possible('webkit-trunk', 'WebKit trunk')
     some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
     other_platform = Platform.create_if_possible('other-platform', 'Other Platform')
     Test.update_or_insert('some-test', webkit_trunk, some_platform)
     Test.update_or_insert('some-test', webkit_trunk, other_platform)
     self.assertEqual(DashboardJSONGenerator().value(), {
         'defaultBranch': 'WebKit trunk',
         'branchToId': {'WebKit trunk': webkit_trunk.id},
         'platformToId': {'Some Platform': some_platform.id, 'Other Platform': other_platform.id},
         'testToId': {'some-test': Test.get_by_key_name('some-test').id},
     })
开发者ID:,项目名称:,代码行数:12,代码来源:

示例4: test_create_if_possible

    def test_create_if_possible(self):
        self.assertThereIsNoInstanceOf(Platform)

        platform = Platform.create_if_possible('some-platform', 'some platform')
        self.assertTrue(platform)
        self.assertTrue(platform.key().name(), 'some-platform')
        self.assertTrue(platform.name, 'some platform')
        self.assertOnlyInstance(platform)

        self.assertFalse(Platform.create_if_possible('some-platform', 'some other platform'))
        self.assertTrue(platform.name, 'some platform')
        self.assertOnlyInstance(platform)
开发者ID:,项目名称:,代码行数:12,代码来源:

示例5: get

    def get(self):
        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8';
        cache = memcache.get('manifest')
        if cache:
            self.response.out.write(cache)
            return

        testMap = {}
        platformIdMap = {}
        branchIdMap = {}
        for test in Test.all():
            branchIds = [Branch.get(branchKey).id for branchKey in test.branches]
            platformIds = [Platform.get(platformKey).id for platformKey in test.platforms]
            testMap[test.id] = {
                'name': test.name,
                'branchIds': branchIds,
                'platformIds': platformIds,
            }

            for platformId in platformIds:
                platformIdMap.setdefault(platformId, {'tests': [], 'branches': []})
                platformIdMap[platformId]['tests'].append(test.id)
                platformIdMap[platformId]['branches'] += branchIds

            for branchId in branchIds:
                branchIdMap.setdefault(branchId, {'tests': [], 'platforms': []})
                branchIdMap[branchId]['tests'].append(test.id)
                branchIdMap[branchId]['platforms'] += platformIds

        platformMap = {}
        for platform in Platform.all():
            if platform.id not in platformIdMap:
                continue
            platformMap[platform.id] = {
                'name': platform.name,
                'testIds': list(set(platformIdMap[platform.id]['tests'])),
                'branchIds': list(set(platformIdMap[platform.id]['branches'])),
            }

        branchMap = {}
        for branch in Branch.all():
            if branch.id not in branchIdMap:
                continue
            branchMap[branch.id] = {
                'name': branch.name,
                'testIds': list(set(branchIdMap[branch.id]['tests'])),
                'platformIds': list(set(branchIdMap[branch.id]['platforms'])),
            }

        result = json.dumps({'testMap': testMap, 'platformMap': platformMap, 'branchMap': branchMap})
        self.response.out.write(result)
        memcache.add('manifest', result)
开发者ID:,项目名称:,代码行数:52,代码来源:

示例6: test_update_or_insert_to_update

    def test_update_or_insert_to_update(self):
        branch = Branch.create_if_possible('some-branch', 'Some Branch')
        platform = Platform.create_if_possible('some-platform', 'Some Platform')
        test = Test.update_or_insert('some-test', branch, platform)
        self.assertOnlyInstance(test)

        other_branch = Branch.create_if_possible('other-branch', 'Other Branch')
        other_platform = Platform.create_if_possible('other-platform', 'Other Platform')
        test = Test.update_or_insert('some-test', other_branch, other_platform, 'ms')
        self.assertOnlyInstance(test)
        self.assertEqualUnorderedList(test.branches, [branch.key(), other_branch.key()])
        self.assertEqualUnorderedList(test.platforms, [platform.key(), other_platform.key()])
        self.assertEqualUnorderedList(test.unit, 'ms')
开发者ID:,项目名称:,代码行数:13,代码来源:

示例7: get

    def get(self):
        self.response.headers['Content-Type'] = 'application/json; charset=utf-8';
        cache = memcache.get('dashboard')
        if cache:
            self.response.out.write(cache)
            return

        webkit_trunk = Branch.get_by_key_name('webkit-trunk')

        # FIXME: Determine popular branches, platforms, and tests
        dashboard = {
            'defaultBranch': 'WebKit trunk',
            'branchToId': {webkit_trunk.name: webkit_trunk.id},
            'platformToId': {},
            'testToId': {},
        }

        for platform in Platform.all():
            dashboard['platformToId'][platform.name] = platform.id

        for test in Test.all():
            dashboard['testToId'][test.name] = test.id

        result = json.dumps(dashboard)
        self.response.out.write(result)
        memcache.add('dashboard', result)
开发者ID:sohocoke,项目名称:webkit,代码行数:26,代码来源:dashboard_handler.py

示例8: test_value_single_platform

    def test_value_single_platform(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        self.assertEqual(ManifestJSONGenerator().value(), {'branchMap': {}, 'platformMap': {}, 'testMap': {}})

        some_test = Test.update_or_insert('some-test', some_branch, some_platform)
        self._assert_single_test(ManifestJSONGenerator().value(), some_branch, some_platform, some_test)
开发者ID:,项目名称:,代码行数:7,代码来源:

示例9: get

    def get(self, campaign_id, platform_name):
        """
        Handles incoming clicks for given campaign_id and platform_name.
        If click is valid then user is redirected to url defined in the campaign
        and statistic about this click is saved. All invalid clicks (e.g. for non
        existing campaigns, platforms) users are redirected to http://outfit7.com.
        """
        # cast campaign_id, type checking is done through route definition
        try:
            campaign_id = int(campaign_id)
        except ValueError:
            return webapp2.redirect("http://outfit7.com", permanent=True)

        platform_id = "%d-%s" % (campaign_id, platform_name)
        platform = Platform.get_by_id(platform_id)
        if platform:
            memcache.incr(platform_id, 1, namespace="counters", initial_value=0)
            try:
                deferred.defer(Platform.increment, platform_id, _countdown=TRACKER_COUNTER_UPDATE_INTERVAL_LENGTH,
                               _name="%s-%d" % (platform_id, get_interval_index()))
            except (taskqueue.TaskAlreadyExistsError, taskqueue.TombstonedTaskError), e:
                pass
            # TODO: optimize with async operations
            campaign = Campaign.get_by_id(campaign_id)
            return webapp2.redirect(campaign.link.encode("utf8"))
开发者ID:AdTech1001,项目名称:ClickTracker-1,代码行数:25,代码来源:tracker.py

示例10: test_update_or_insert

    def test_update_or_insert(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch, some_platform)
        self.assertThereIsNoInstanceOf(Runs)

        runs = Runs.update_or_insert(some_branch, some_platform, some_test)
        self.assertOnlyInstance(runs)
        self.assertEqual(runs.json_runs, '')
        self.assertEqual(runs.json_averages, '')
        self.assertEqual(runs.json_min, None)
        self.assertEqual(runs.json_max, None)
        old_memcache_value = memcache.get(Runs._key_name(some_branch.id, some_platform.id, some_test.id))
        self.assertTrue(old_memcache_value)

        runs.delete()
        self.assertThereIsNoInstanceOf(Runs)

        builds, results = self._create_results(some_branch, some_platform, some_builder, 'some-test', [50.0])
        runs = Runs.update_or_insert(some_branch, some_platform, some_test)
        self.assertOnlyInstance(runs)
        self.assertTrue(runs.json_runs.startswith('[5, [4, 0, 100, null],'))
        self.assertEqual(json.loads('{' + runs.json_averages + '}'), {"100": 50.0})
        self.assertEqual(runs.json_min, 50.0)
        self.assertEqual(runs.json_max, 50.0)
        self.assertNotEqual(memcache.get(Runs._key_name(some_branch.id, some_platform.id, some_test.id)), old_memcache_value)
开发者ID:,项目名称:,代码行数:27,代码来源:

示例11: test_to_json_with_results

    def test_to_json_with_results(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch, some_platform)
        builds, results = self._create_results(some_branch, some_platform, some_builder, 'some-test', [50.0, 51.0, 52.0, 49.0, 48.0])

        value = json.loads(Runs.update_or_insert(some_branch, some_platform, some_test).to_json())
        self.assertEqualUnorderedList(value.keys(), ['test_runs', 'averages', 'min', 'max', 'unit', 'date_range', 'stat'])
        self.assertEqual(value['stat'], 'ok')
        self.assertEqual(value['min'], 48.0)
        self.assertEqual(value['max'], 52.0)
        self.assertEqual(value['unit'], None)
        self.assertEqual(value['date_range'], None)  # date_range is never given

        self.assertEqual(len(value['test_runs']), len(results))
        for i, run in enumerate(value['test_runs']):
            result = results[i]
            self.assertEqual(run[0], result.key().id())
            self.assertEqual(run[1][1], i)  # Build number
            self.assertEqual(run[1][2], 100 + i)  # Revision
            self.assertEqual(run[1][3], None)  # Supplementary revision
            self.assertEqual(run[3], result.value)
            self.assertEqual(run[6], some_builder.key().id())
            self.assertEqual(run[7], None)  # Statistics
开发者ID:,项目名称:,代码行数:25,代码来源:

示例12: test_chart_params_with_value

    def test_chart_params_with_value(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch, some_platform)

        start_time = datetime(2011, 2, 21, 12, 0, 0)
        end_time = datetime(2011, 2, 28, 12, 0, 0)
        results = self._create_results(some_branch, some_platform, some_builder, 'some-test',
            [50.0, 51.0, 52.0, 49.0, 48.0, 51.9, 50.7, 51.1],
            [start_time + timedelta(day) for day in range(0, 8)])

        # Use int despite of its impreciseness since tests may fail due to rounding errors otherwise.
        def split_as_int(string):
            return [int(float(value)) for value in string.split(',')]

        params = Runs.update_or_insert(some_branch, some_platform, some_test).chart_params(7)
        self.assertEqual(params['chxl'], '0:|Feb 21|Feb 22|Feb 23|Feb 24|Feb 25|Feb 26|Feb 27|Feb 28')
        self.assertEqual(split_as_int(params['chxr']), [1, 0, 57, int(52 * 1.1 / 5 + 0.5)])
        x_min, x_max, y_min, y_max = split_as_int(params['chds'])
        self.assertEqual(datetime.fromtimestamp(x_min), start_time)
        self.assertEqual(datetime.fromtimestamp(x_max), end_time)
        self.assertEqual(y_min, 0)
        self.assertEqual(y_max, int(52 * 1.1))
        self.assertEqual(split_as_int(params['chg']), [int(100 / 7), 20, 0, 0])

        params = Runs.update_or_insert(some_branch, some_platform, some_test).chart_params(14)
        self.assertEqual(params['chxl'], '0:|Feb 14|Feb 16|Feb 18|Feb 20|Feb 22|Feb 24|Feb 26|Feb 28')
        self.assertEqual(split_as_int(params['chxr']), [1, 0, 57, int(52 * 1.1 / 5 + 0.5)])
        x_min, x_max, y_min, y_max = split_as_int(params['chds'])
        self.assertEqual(datetime.fromtimestamp(x_min), datetime(2011, 2, 14, 12, 0, 0))
        self.assertEqual(datetime.fromtimestamp(x_max), end_time)
        self.assertEqual(y_min, 0)
        self.assertEqual(y_max, int(52 * 1.1))
        self.assertEqual(split_as_int(params['chg']), [int(100 / 7), 20, 0, 0])
开发者ID:,项目名称:,代码行数:35,代码来源:

示例13: test_update_incrementally

    def test_update_incrementally(self):
        some_branch = Branch.create_if_possible('some-branch', 'Some Branch')
        some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
        some_builder = Builder.get(Builder.create('some-builder', 'Some Builder'))
        some_test = Test.update_or_insert('some-test', some_branch, some_platform)
        self.assertThereIsNoInstanceOf(Runs)

        timestamps = [datetime.now(), datetime.now()]
        builds, results = self._create_results(some_branch, some_platform, some_builder, 'some-test', [50.0, 52.0], timestamps)
        runs = Runs.update_or_insert(some_branch, some_platform, some_test)
        self.assertOnlyInstance(runs)
        self.assertEqual(json.loads('[' + runs.json_runs + ']'),
            [[5, [4, 0, 100, None], mktime(timestamps[0].timetuple()), 50.0, 0, [], None, None],
            [7, [6, 1, 101, None], mktime(timestamps[1].timetuple()), 52.0, 0, [], None, None]])
        self.assertEqual(json.loads('{' + runs.json_averages + '}'), {"100": 50.0, "101": 52.0})
        self.assertEqual(runs.json_min, 50.0)
        self.assertEqual(runs.json_max, 52.0)

        timestamps.append(datetime.now())
        builds, results = self._create_results(some_branch, some_platform, some_builder, 'some-test', [48.0],
            timestamps[2:], starting_revision=102)
        runs.update_incrementally(builds[0], results[0])

        self.assertOnlyInstance(runs)
        self.assertEqual(json.loads('[' + runs.json_runs + ']'),
            [[5, [4, 0, 100, None], mktime(timestamps[0].timetuple()), 50.0, 0, [], None, None],
            [7, [6, 1, 101, None], mktime(timestamps[1].timetuple()), 52.0, 0, [], None, None],
            [9, [8, 0, 102, None], mktime(timestamps[2].timetuple()), 48.0, 0, [], None, None]])
        self.assertEqual(json.loads('{' + runs.json_averages + '}'), {"100": 50.0, "101": 52.0, "102": 48.0})
        self.assertEqual(runs.json_min, 48.0)
        self.assertEqual(runs.json_max, 52.0)
开发者ID:,项目名称:,代码行数:31,代码来源:

示例14: post

    def post(self):
        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'

        try:
            payload = json.loads(self.request.body)
            hide = payload['hide']
        except:
            self.response.out.write("Failed to parse the payload: %s" % self.request.body)
            return

        if 'platform' in payload:
            model = Platform.get_by_key_name(payload['platform'])
        elif 'test' in payload:
            model = Test.get_by_key_name(payload['test'])
        else:
            self.response.out.write('Not supported')
            return

        if not model:
            self.response.out.write('Could not find the model')
            return

        model.hidden = hide
        model.put()
        schedule_dashboard_update()
        schedule_manifest_update()

        self.response.out.write('OK')
开发者ID:EQ4,项目名称:h5vcc,代码行数:28,代码来源:admin_handlers.py

示例15: test_value_with_hidden_platform_and_tesst

 def test_value_with_hidden_platform_and_tesst(self):
     webkit_trunk = Branch.create_if_possible('webkit-trunk', 'WebKit trunk')
     some_platform = Platform.create_if_possible('some-platform', 'Some Platform')
     hidden_platform = Platform.create_if_possible('hidden-platform', 'Hidden Platform')
     hidden_platform.hidden = True
     hidden_platform.put()
     Test.update_or_insert('some-test', webkit_trunk, some_platform)
     Test.update_or_insert('some-test', webkit_trunk, hidden_platform)
     Test.update_or_insert('other-test', webkit_trunk, some_platform)
     Test.update_or_insert('other-test', webkit_trunk, hidden_platform)
     Test.update_or_insert('hidden-test', webkit_trunk, some_platform)
     Test.update_or_insert('hidden-test', webkit_trunk, hidden_platform)
     hidden_test = Test.get_by_key_name('hidden-test')
     hidden_test.hidden = True
     hidden_test.put()
     self.assertEqual(DashboardJSONGenerator().value()['platformToId'], {'Some Platform': some_platform.id})
     self.assertEqual(DashboardJSONGenerator().value()['testToId'],
         {'some-test': Test.get_by_key_name('some-test').id, 'other-test': Test.get_by_key_name('other-test').id})
开发者ID:EQ4,项目名称:h5vcc,代码行数:18,代码来源:json_generators_unittest.py


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