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


Python DocumentIO.load方法代码示例

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


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

示例1: _get_bundles

# 需要导入模块: from linaro_dashboard_bundle.io import DocumentIO [as 别名]
# 或者: from linaro_dashboard_bundle.io.DocumentIO import load [as 别名]
    def _get_bundles(self, files):
        bundles = []
        errors = []
        for fname in files:
            if os.path.splitext(fname)[1] != ".bundle":
                continue
            content = None
            try:
                with open(fname, 'r') as f:
                    doc = DocumentIO.load(f)[1]
                DocumentEvolution.evolve_document(doc)
                bundles.append(doc)
            except ValueError:
                msg = 'Error adding result bundle %s' % fname
                errors.append(msg)
                logging.exception(msg)
                if content:
                    logging.info('Adding bundle as attachment')
                    attachment = create_attachment(fname, content)
                    self.context.test_data.add_attachments([attachment])
            except KeyboardInterrupt:
                raise KeyboardInterrupt
            except:
                msg = 'Unknown error processing bundle' % fname
                logging.exception(msg)
                errors.append(msg)

        if len(errors) > 0:
            msg = ' '.join(errors)
            raise GatherResultsError(msg, bundles)
        return bundles
开发者ID:inwotep,项目名称:lava-dispatcher,代码行数:33,代码来源:launch_control.py

示例2: _get_results_from_host

# 需要导入模块: from linaro_dashboard_bundle.io import DocumentIO [as 别名]
# 或者: from linaro_dashboard_bundle.io.DocumentIO import load [as 别名]
    def _get_results_from_host(self):
        bundles = []
        errors = []
        try:
            bundle_list = os.listdir(self.context.host_result_dir)
            for bundle_name in bundle_list:
                bundle = "%s/%s" % (self.context.host_result_dir, bundle_name)
                content = None
                try:
                    with open(bundle) as f:
                        doc = DocumentIO.load(f)[1]
                    DocumentEvolution.evolve_document(doc)
                    bundles.append(doc)
                except ValueError:
                    msg = 'Error adding host result bundle %s' % bundle
                    errors.append(msg)
                    logging.exception(msg)
                    if content:
                        logging.info('Adding bundle as attachment')
                        attachment = create_attachment(bundle, content)
                        self.context.test_data.add_attachments([attachment])
        except:
            msg = 'Error getting all results from host'
            logging.exception(msg)
            raise GatherResultsError(msg, bundles)

        if len(errors) > 0:
            msg = ' '.join(errors)
            raise GatherResultsError(msg, bundles)

        return bundles
开发者ID:inwotep,项目名称:lava-dispatcher,代码行数:33,代码来源:launch_control.py

示例3: test_evolved_document_is_what_we_expect

# 需要导入模块: from linaro_dashboard_bundle.io import DocumentIO [as 别名]
# 或者: from linaro_dashboard_bundle.io.DocumentIO import load [as 别名]
 def test_evolved_document_is_what_we_expect(self):
     DocumentEvolution.evolve_document(self.doc, one_step=True)
     fmt, evolved_doc = DocumentIO.load(
         resource_stream('linaro_dashboard_bundle',
                         'test_documents/evolution_1.7.1.json'),
         retain_order=False)
     self.assertEqual(self.doc, evolved_doc)
开发者ID:Bruce-Zou,项目名称:lava-dispatcher,代码行数:9,代码来源:tests.py

示例4: test_load_document

# 需要导入模块: from linaro_dashboard_bundle.io import DocumentIO [as 别名]
# 或者: from linaro_dashboard_bundle.io.DocumentIO import load [as 别名]
 def test_load_document(self):
     # Note: resource_string uses posix-style paths
     # regardless of the actual system paths
     fmt, doc = DocumentIO.load(
         resource_stream('linaro_dashboard_bundle',
                         'test_documents/' + self.filename))
     self.assertIsNot(doc, None)
开发者ID:Bruce-Zou,项目名称:lava-dispatcher,代码行数:9,代码来源:tests.py

示例5: _load_bundle

# 需要导入模块: from linaro_dashboard_bundle.io import DocumentIO [as 别名]
# 或者: from linaro_dashboard_bundle.io.DocumentIO import load [as 别名]
    def _load_bundle(self, local_pathname):
        """
        Load the bundle from local_pathname.

        There are various problems that can happen here but
        they should all be treated equally, the bundle not
        being used. This also transparently does schema validation
        so the chance of getting wrong data is lower.
        """
        with open(local_pathname, 'rt') as stream:
            format, bundle = DocumentIO.load(stream)
            return format, bundle
开发者ID:inwotep,项目名称:lava-android-test,代码行数:14,代码来源:blackbox.py

示例6: deserialize

# 需要导入模块: from linaro_dashboard_bundle.io import DocumentIO [as 别名]
# 或者: from linaro_dashboard_bundle.io.DocumentIO import load [as 别名]
    def deserialize(self, s_bundle, prefer_evolution):
        """
        Deserializes specified Bundle.

        :Discussion:
            This method also handles internal transaction handling.
            All operations performed during bundle deserialization are
            _rolled_back_ if anything fails.

            If prefer_evolution is enabled then the document is first evolved
            to the latest known format and only then imported into the
            database. This operation is currently disabled to ensure that all
            old documents are imported exactly as before. Enabling it should
            be quite safe though as it passes all tests.

        :Exceptions raised:
            json_schema_validator.ValidationError
                When the document does not match the appropriate schema.
            linaro_dashboard_bundle.errors.DocumentFormatError
                When the document format is not in the known set of formats.
            ValueError
                When the text does not represent a correct JSON document.
        """
        assert s_bundle.is_deserialized is False
        s_bundle.content.open('rb')
        logger = logging.getLogger(__name__)
        try:
            logger.debug("Loading document")
            fmt, doc = DocumentIO.load(s_bundle.content)
            logger.debug("Document loaded")
            if prefer_evolution:
                logger.debug("Evolving document")
                DocumentEvolution.evolve_document(doc)
                logger.debug("Document evolution complete")
                fmt = doc["format"]
        finally:
            s_bundle.content.close()
        importer = self.IMPORTERS.get(fmt)
        if importer is None:
            raise DocumentFormatError(fmt)
        try:
            logger.debug("Importing document")
            importer().import_document(s_bundle, doc)
            logger.debug("Document import complete")
        except Exception as exc:
            logger.debug("Exception while importing document: %r", exc)
            raise
开发者ID:SivagnanamCiena,项目名称:lava-server,代码行数:49,代码来源:helpers.py

示例7: test_load__with_disabled_retain_order__dict_class

# 需要导入模块: from linaro_dashboard_bundle.io import DocumentIO [as 别名]
# 或者: from linaro_dashboard_bundle.io.DocumentIO import load [as 别名]
 def test_load__with_disabled_retain_order__dict_class(self):
     fmt, doc = DocumentIO.load(self.stream, retain_order=False)
     expected_impl = dict
     observed_impl = type(doc)
     self.assertEqual(observed_impl, expected_impl)
开发者ID:Bruce-Zou,项目名称:lava-dispatcher,代码行数:7,代码来源:tests.py

示例8: test_load__with_enabled_retain_order__dict_class

# 需要导入模块: from linaro_dashboard_bundle.io import DocumentIO [as 别名]
# 或者: from linaro_dashboard_bundle.io.DocumentIO import load [as 别名]
 def test_load__with_enabled_retain_order__dict_class(self):
     fmt, doc = DocumentIO.load(self.stream, retain_order=True)
     observed_impl = type(doc)
     # Note:    VVV
     self.assertNotEqual(observed_impl, dict)
开发者ID:Bruce-Zou,项目名称:lava-dispatcher,代码行数:7,代码来源:tests.py

示例9: test_load__with_enabled_retain_order__key_order

# 需要导入模块: from linaro_dashboard_bundle.io import DocumentIO [as 别名]
# 或者: from linaro_dashboard_bundle.io.DocumentIO import load [as 别名]
 def test_load__with_enabled_retain_order__key_order(self):
     fmt, doc = DocumentIO.load(self.stream, retain_order=True)
     observed_keys = doc.keys()
     self.assertEqual(observed_keys, self.expected_keys)
开发者ID:Bruce-Zou,项目名称:lava-dispatcher,代码行数:6,代码来源:tests.py

示例10: setUp

# 需要导入模块: from linaro_dashboard_bundle.io import DocumentIO [as 别名]
# 或者: from linaro_dashboard_bundle.io.DocumentIO import load [as 别名]
 def setUp(self):
     super(DocumentEvolutionTests_1_7_to_1_7_1, self).setUp()
     self.fmt, self.doc = DocumentIO.load(
         resource_stream('linaro_dashboard_bundle',
                         'test_documents/evolution_1.7.json'),
         retain_order=False)
开发者ID:Bruce-Zou,项目名称:lava-dispatcher,代码行数:8,代码来源:tests.py

示例11: test_load__return_value

# 需要导入模块: from linaro_dashboard_bundle.io import DocumentIO [as 别名]
# 或者: from linaro_dashboard_bundle.io.DocumentIO import load [as 别名]
 def test_load__return_value(self):
     fmt, doc = DocumentIO.load(self.stream)
     self.assertEqual(fmt, self.expected_fmt)
     self.assertEqual(doc, self.expected_doc)
开发者ID:Bruce-Zou,项目名称:lava-dispatcher,代码行数:6,代码来源:tests.py


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