當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。