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


Python DataFileElement.get_bytes方法代码示例

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


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

示例1: test_get_bytes_no_file

# 需要导入模块: from smqtk.representation.data_element.file_element import DataFileElement [as 别名]
# 或者: from smqtk.representation.data_element.file_element.DataFileElement import get_bytes [as 别名]
 def test_get_bytes_no_file(self):
     e = DataFileElement("/not/a/valid/path.txt", readonly=True)
     # We currently expect, in the case where the filepath doesn't exist, to
     # get the same bytes as if the file existed and were empty.
     self.assertEqual(e.get_bytes(), six.b(""))
     # read-only status should have no effect.
     e = DataFileElement("/not/a/valid/path.txt", readonly=True)
     self.assertEqual(e.get_bytes(), six.b(""))
开发者ID:Kitware,项目名称:SMQTK,代码行数:10,代码来源:test_DataFileElement.py

示例2: iqr_ingest_file

# 需要导入模块: from smqtk.representation.data_element.file_element import DataFileElement [as 别名]
# 或者: from smqtk.representation.data_element.file_element.DataFileElement import get_bytes [as 别名]
        def iqr_ingest_file():
            """
            Ingest the file with the given UID, getting the path from the
            uploader.

            :return: string of data/descriptor element's UUID
            :rtype: str

            """
            # TODO: Add status dict with a "GET" method branch for getting that
            #       status information.

            fid = flask.request.form['fid']

            sid = self.get_current_iqr_session()

            self._log.debug("[%s::%s] Getting temporary filepath from "
                            "uploader module", sid, fid)
            upload_filepath = self.mod_upload.get_path_for_id(fid)
            self.mod_upload.clear_completed(fid)

            self._log.debug("[%s::%s] Moving uploaded file",
                            sid, fid)
            sess_upload = osp.join(self._iqr_work_dirs[sid],
                                   osp.basename(upload_filepath))
            os.rename(upload_filepath, sess_upload)

            # Record uploaded data as user example data for this session.
            upload_data = DataFileElement(sess_upload)
            uuid = upload_data.uuid()
            self._iqr_example_data[sid][uuid] = upload_data

            # Extend session ingest -- modifying
            self._log.debug("[%s::%s] Adding new data to session "
                            "external positives", sid, fid)
            data_b64 = base64.b64encode(upload_data.get_bytes())
            data_ct = upload_data.content_type()
            r = self._iqr_service.post('add_external_pos', sid=sid,
                                       base64=data_b64, content_type=data_ct)
            r.raise_for_status()

            return str(uuid)
开发者ID:Kitware,项目名称:SMQTK,代码行数:44,代码来源:iqr_search.py

示例3: test_get_bytes

# 需要导入模块: from smqtk.representation.data_element.file_element import DataFileElement [as 别名]
# 或者: from smqtk.representation.data_element.file_element.DataFileElement import get_bytes [as 别名]
 def test_get_bytes(self):
     # Test with a known real file.
     test_file_path = os.path.join(TEST_DATA_DIR, 'text_file')
     e = DataFileElement(test_file_path)
     self.assertEqual(e.get_bytes(), six.b("Some text content.\n"))
开发者ID:Kitware,项目名称:SMQTK,代码行数:7,代码来源:test_DataFileElement.py


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