本文整理汇总了Python中models.Build.all方法的典型用法代码示例。如果您正苦于以下问题:Python Build.all方法的具体用法?Python Build.all怎么用?Python Build.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Build
的用法示例。
在下文中一共展示了Build.all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Build [as 别名]
# 或者: from models.Build import all [as 别名]
def get(self):
self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
try:
testId = int(self.request.get('id', 0))
branchId = int(self.request.get('branchid', 0))
platformId = int(self.request.get('platformid', 0))
except TypeError:
# FIXME: Output an error here
testId = 0
branchId = 0
platformId = 0
# FIXME: Just fetch builds specified by "days"
# days = self.request.get('days', 365)
cacheKey = Test.cacheKey(testId, branchId, platformId)
cache = memcache.get(cacheKey)
if cache:
self.response.out.write(cache)
return
builds = Build.all()
builds.filter('branch =', modelFromNumericId(branchId, Branch))
builds.filter('platform =', modelFromNumericId(platformId, Platform))
test = modelFromNumericId(testId, Test)
testName = test.name if test else None
test_runs = []
averages = {}
values = []
timestamps = []
for build in builds:
results = TestResult.all()
results.filter('name =', testName)
results.filter('build =', build)
for result in results:
builderId = build.builder.key().id()
posixTimestamp = mktime(build.timestamp.timetuple())
test_runs.append([result.key().id(),
[build.key().id(), build.buildNumber, build.revision],
posixTimestamp, result.value, 0, [], builderId])
# 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(cacheKey, result)
示例2: post
# 需要导入模块: from models import Build [as 别名]
# 或者: from models.Build import all [as 别名]
def post(self):
self.response.headers['Content-Type'] = 'text/plain; 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)
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'})
cache_runs(test_id, branch_id, platform_id, result)
self.response.out.write('OK')
示例3: _generate_runs
# 需要导入模块: from models import Build [as 别名]
# 或者: from models.Build import all [as 别名]
def _generate_runs(branch, platform, test_name):
builds = Build.all()
builds.filter('branch =', branch)
builds.filter('platform =', platform)
for build in builds:
results = TestResult.all()
results.filter('name =', test_name)
results.filter('build =', build)
for result in results:
yield build, result
raise StopIteration