当前位置: 首页>>代码示例>>Python>>正文


Python DocumentIO.dump方法代码示例

本文整理汇总了Python中linaro_dashboard_bundle.io.DocumentIO.dump方法的典型用法代码示例。如果您正苦于以下问题:Python DocumentIO.dump方法的具体用法?Python DocumentIO.dump怎么用?Python DocumentIO.dump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在linaro_dashboard_bundle.io.DocumentIO的用法示例。


在下文中一共展示了DocumentIO.dump方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: invoke_sub

# 需要导入模块: from linaro_dashboard_bundle.io import DocumentIO [as 别名]
# 或者: from linaro_dashboard_bundle.io.DocumentIO import dump [as 别名]
    def invoke_sub(self):
        tip_msg = self.get_tip_msg("Run test")
        self.say_begin(tip_msg)

        if not self.test_installed(self.args.test_id):
            raise LavaCommandError(
                "The test (%s) has not been installed yet." %
                self.args.test_id)
        test = TestProvider().load_test(self.args.test_id, self.args.serial)

        if not self.test_installed(test.testname):
            raise LavaCommandError(
                    "The test (%s) has not been installed yet."
                    % self.args.test_id)

        try:
            result_id = test.run(quiet=self.args.quiet,
                                  run_options=self.args.run_option)
            if self.args.output:
                output_dir = os.path.dirname(self.args.output)
                if output_dir and (not os.path.exists(output_dir)):
                    os.makedirs(output_dir)
                bundle = generate_bundle(self.args.serial, result_id)
                with open(self.args.output, "wt") as stream:
                    DocumentIO.dump(stream, bundle)

        except Exception as strerror:
            raise LavaCommandError("Test execution error: %s" % strerror)

        self.say_end(tip_msg)
开发者ID:inwotep,项目名称:lava-android-test,代码行数:32,代码来源:commands.py

示例2: _bundle_results

# 需要导入模块: from linaro_dashboard_bundle.io import DocumentIO [as 别名]
# 或者: from linaro_dashboard_bundle.io.DocumentIO import dump [as 别名]
    def _bundle_results(self, target, signal_director, testdef_objs):
        """ Pulls the results from the target device and builds a bundle
        """
        results_part = target.deployment_data['lava_test_results_part_attr']
        results_part = getattr(target.config, results_part)
        rdir = self.context.host_result_dir
        parse_err_msg = None

        filesystem_access_failure = True

        try:
            with target.file_system(results_part, target.lava_test_results_dir) as d:
                filesystem_access_failure = False
                err_log = os.path.join(d, 'parse_err.log')
                results_dir = os.path.join(d, 'results')
                bundle = lava_test_shell.get_bundle(results_dir, testdef_objs, err_log)
                parse_err_msg = read_content(err_log, ignore_missing=True)
                if os.path.isfile(err_log):
                    os.unlink(err_log)
                # lava/results must be empty, but we keep a copy named
                # lava/results-XXXXXXXXXX for post-mortem analysis
                timestamp = datetime.now().strftime("%s")
                os.rename(results_dir, results_dir + '-' + timestamp)
                utils.ensure_directory(results_dir)
        except Exception as e:
            if filesystem_access_failure:
                # a failure when accessing the filesystem means the device
                # probably crashed. We use the backup bundle then.
                bundle = self._backup_bundle
                logging.warning(
                    """Error extracting test results from device: %s""" % e)
                logging.warning(
                    """This may mean that the device under test crashed. """
                    """We will use test results parsed from the serial """
                    """output as a backup, but note that some test """
                    """artifacts (such as attachments and """
                    """hardware/software contexts) will not be available""")
            else:
                raise e

        signal_director.postprocess_bundle(bundle)

        (fd, name) = tempfile.mkstemp(
            prefix='lava-test-shell', suffix='.bundle', dir=rdir)
        with os.fdopen(fd, 'w') as f:
            DocumentIO.dump(f, bundle)

        printer = PrettyPrinter(self.context)
        printer.print_results(bundle)

        if parse_err_msg:
            raise GeneralError(parse_err_msg)
开发者ID:inwotep,项目名称:lava-dispatcher,代码行数:54,代码来源:lava_test_shell.py

示例3: _write_results_bundle

# 需要导入模块: from linaro_dashboard_bundle.io import DocumentIO [as 别名]
# 或者: from linaro_dashboard_bundle.io.DocumentIO import dump [as 别名]
 def _write_results_bundle(self, bundle):
     rdir = self.context.host_result_dir
     (fd, name) = tempfile.mkstemp(
         prefix='lava-command', suffix='.bundle', dir=rdir)
     with os.fdopen(fd, 'w') as f:
         DocumentIO.dump(f, bundle)
开发者ID:Bruce-Zou,项目名称:lava-dispatcher,代码行数:8,代码来源:lava_command.py

示例4: test_dump_produces_compact_sorted_output

# 需要导入模块: from linaro_dashboard_bundle.io import DocumentIO [as 别名]
# 或者: from linaro_dashboard_bundle.io.DocumentIO import dump [as 别名]
 def test_dump_produces_compact_sorted_output(self):
     stream = StringIO()
     DocumentIO.dump(stream, self.doc, human_readable=False, sort_keys=True)
     observed_text = stream.getvalue()
     self.assertEqual(observed_text, self.expected_compact_sorted_text)
开发者ID:Bruce-Zou,项目名称:lava-dispatcher,代码行数:7,代码来源:tests.py


注:本文中的linaro_dashboard_bundle.io.DocumentIO.dump方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。