当前位置: 首页>>代码示例>>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;未经允许,请勿转载。