本文整理汇总了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)
示例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)
示例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)
示例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)