本文整理汇总了Python中model.testfile.TestFile.overwrite_or_add_file方法的典型用法代码示例。如果您正苦于以下问题:Python TestFile.overwrite_or_add_file方法的具体用法?Python TestFile.overwrite_or_add_file怎么用?Python TestFile.overwrite_or_add_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.testfile.TestFile
的用法示例。
在下文中一共展示了TestFile.overwrite_or_add_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model.testfile import TestFile [as 别名]
# 或者: from model.testfile.TestFile import overwrite_or_add_file [as 别名]
def post(self):
file_params = self.request.POST.getall(PARAM_FILE)
if not file_params:
self.response.out.write("FAIL: missing upload file field.")
return
builder = self.request.get(PARAM_BUILDER)
if not builder:
self.response.out.write("FAIL: missing builder parameter.")
return
master = self.request.get(PARAM_MASTER)
test_type = self.request.get(PARAM_TEST_TYPE)
logging.debug(
"Processing upload request, master: %s, builder: %s, test_type: %s.",
master, builder, test_type)
# There are two possible types of each file_params in the request:
# one file item or a list of file items.
# Normalize file_params to a file item list.
files = []
logging.debug("test: %s, type:%s", file_params, type(file_params))
for item in file_params:
if not isinstance(item, list) and not isinstance(item, tuple):
item = [item]
files.extend(item)
errors = []
final_status_code = 200
for file in files:
if file.filename == "incremental_results.json":
status_string, status_code = JsonResults.update(master, builder, test_type, file.value, is_full_results_format=False)
elif file.filename == "times_ms.json":
# We never look at historical times_ms.json files, so we can overwrite the existing one if it exists.
status_string, status_code = TestFile.overwrite_or_add_file(master, builder, test_type, file.filename, file.value)
else:
status_string, status_code = TestFile.add_file(master, builder, test_type, file.filename, file.value)
# FIXME: Upload full_results.json files for non-layout tests as well and stop supporting the
# incremental_results.json file format.
if status_code == 200 and file.filename == "full_results.json":
status_string, status_code = JsonResults.update(master, builder, test_type, file.value, is_full_results_format=True)
if status_code == 200:
logging.info(status_string)
else:
logging.error(status_string)
errors.append(status_string)
final_status_code = status_code
if errors:
messages = "FAIL: " + "; ".join(errors)
self.response.set_status(final_status_code, messages)
self.response.out.write(messages)
else:
self.response.set_status(200)
self.response.out.write("OK")