當前位置: 首頁>>代碼示例>>Python>>正文


Python TestFile.overwrite_or_add_file方法代碼示例

本文整理匯總了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")
開發者ID:Drakey83,項目名稱:steamlink-sdk,代碼行數:59,代碼來源:testfilehandler.py


注:本文中的model.testfile.TestFile.overwrite_or_add_file方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。