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


Python testfile.TestFile類代碼示例

本文整理匯總了Python中model.testfile.TestFile的典型用法代碼示例。如果您正苦於以下問題:Python TestFile類的具體用法?Python TestFile怎麽用?Python TestFile使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TestFile類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: post

    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,代碼行數:57,代碼來源:testfilehandler.py

示例2: _get_file

    def _get_file(cls, master, builder, test_type, filename):
        files = TestFile.get_files(master, builder, test_type, filename)
        if files:
            return files[0]

        file = TestFile()
        file.master = master
        file.builder = builder
        file.test_type = test_type
        file.name = filename
        file.data = ""
        return file
開發者ID:hinike,項目名稱:opera,代碼行數:12,代碼來源:jsonresults.py

示例3: _get_file_content

    def _get_file_content(self, master, builder, test_type, build_number, name):
        """Return content of the file that matches builder and file name.

        Args:
            builder: builder name
            test_type: type of the test
            build_number: build number, or 'latest'
            name: file name
        """

        files = TestFile.get_files(
            master, builder, test_type, build_number, name, load_data=True, limit=1)
        if not files:
            logging.info("File not found, master %s, builder: %s, test_type: %s, build_number: %s, name: %s.",
                         master, builder, test_type, build_number, name)
            return None, None

        return files[0].data, files[0].date
開發者ID:darktears,項目名稱:blink-crosswalk,代碼行數:18,代碼來源:testfilehandler.py

示例4: get

    def get(self):
        key = self.request.get(PARAM_KEY)
        master = self.request.get(PARAM_MASTER)
        builder = self.request.get(PARAM_BUILDER)
        test_type = self.request.get(PARAM_TEST_TYPE)
        name = self.request.get(PARAM_NAME)
        num_files = self.request.get(PARAM_NUM_FILES)
        before = self.request.get(PARAM_BEFORE)

        logging.debug(
            "Deleting File, master: %s, builder: %s, test_type: %s, name: %s, before: %s, key: %s.",
            master, builder, test_type, name, before, key)

        limit = int(num_files) if num_files else 1
        num_deleted = TestFile.delete_file(key, master, builder, test_type, name, before, limit)

        self.response.set_status(200)
        self.response.out.write("Deleted %d files." % num_deleted)
開發者ID:Drakey83,項目名稱:steamlink-sdk,代碼行數:18,代碼來源:testfilehandler.py

示例5: get

    def get(self):
        key = self.request.get(PARAM_KEY)
        # Intentionally don't munge the master from deprecated names here.
        # Assume anyone deleting files wants explicit control.
        master = self.request.get(PARAM_MASTER)
        builder = self.request.get(PARAM_BUILDER)
        test_type = self.request.get(PARAM_TEST_TYPE)
        build_number = self.request.get(PARAM_BUILD_NUMBER, default_value=None)
        name = self.request.get(PARAM_NAME)
        num_files = self.request.get(PARAM_NUM_FILES)
        before = self.request.get(PARAM_BEFORE)

        logging.debug(
            "Deleting File, master: %s, builder: %s, test_type: %s, build_number: %s, name: %s, before: %s, key: %s.",
            master, builder, test_type, build_number, name, before, key)

        limit = int(num_files) if num_files else 1
        num_deleted = TestFile.delete_file(key, master, builder, test_type, build_number, name, before, limit)

        self.response.set_status(200)
        self.response.out.write("Deleted %d files." % num_deleted)
開發者ID:darktears,項目名稱:blink-crosswalk,代碼行數:21,代碼來源:testfilehandler.py

示例6: update_file

    def update_file(cls, master, builder, test_type, incremental, filename, num_runs):
        files = TestFile.get_files(master, builder, test_type, filename)
        if files:
            file = files[0]
            new_results = cls.merge(builder, file.data, incremental, num_runs)
        else:
            # Use the incremental data if there is no aggregated file to merge.
            file = TestFile()
            file.master = master
            file.builder = builder
            file.test_type = test_type
            file.name = filename
            new_results = incremental
            logging.info("No existing json results, incremental json is saved.")

        if not new_results or not file.save(new_results):
            logging.info("Update failed, master: %s, builder: %s, test_type: %s, name: %s." % (master, builder, test_type, filename))
            return False

        return True
開發者ID:dzhshf,項目名稱:WebKit,代碼行數:20,代碼來源:jsonresults.py

示例7: update_file

 def update_file(cls, builder, file, incremental_json, num_runs):
     new_results, status_code = cls.merge(builder, file.data, incremental_json, num_runs)
     if status_code != 200:
         return new_results, status_code
     return TestFile.save_file(file, new_results)
開發者ID:hinike,項目名稱:opera,代碼行數:5,代碼來源:jsonresults.py

示例8: post

    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_parameter = self.request.get(PARAM_MASTER)

        master_data = master_config.getMasterByMasterName(master_parameter)
        if master_data:
            deprecated_master = master_parameter
            master = master_data['url_name']
        else:
            deprecated_master = None
            master = master_parameter

        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:
            file_json = JsonResults._load_json(file.value)
            if file.filename == "incremental_results.json":
                # FIXME: Ferret out and eliminate remaining incremental_results.json producers.
                logging.info("incremental_results.json received from master: %s, builder: %s, test_type: %s.",
                             master, builder, test_type)
                status_string, status_code = JsonResults.update(master, builder, test_type, file_json,
                    deprecated_master=deprecated_master, is_full_results_format=False)
            else:
                try:
                    build_number = int(file_json.get('build_number', 0))
                    status_string, status_code = TestFile.add_file(master, builder, test_type, build_number, file.filename, file.value)
                except (ValueError, TypeError):
                    status_code = 403
                    status_string = 'Could not cast the build_number field in the json to an integer.'

                if status_code == 200:
                    logging.info(status_string)
                else:
                    logging.error(status_string)
                    errors.append(status_string)
                    final_status_code = status_code

            if status_code == 200 and file.filename == "full_results.json":
                status_string, status_code = JsonResults.update(master, builder, test_type, file_json,
                    deprecated_master=deprecated_master, 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:darktears,項目名稱:blink-crosswalk,代碼行數:80,代碼來源:testfilehandler.py


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