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


Python common.AzureHttpError方法代码示例

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


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

示例1: wasb_read

# 需要导入模块: from azure import common [as 别名]
# 或者: from azure.common import AzureHttpError [as 别名]
def wasb_read(self, remote_log_location, return_error=False):
        """
        Returns the log found at the remote_log_location. Returns '' if no
        logs are found or there is an error.

        :param remote_log_location: the log's location in remote storage
        :type remote_log_location: str (path)
        :param return_error: if True, returns a string error message if an
            error occurs. Otherwise returns '' when an error occurs.
        :type return_error: bool
        """
        try:
            return self.hook.read_file(self.wasb_container, remote_log_location)
        except AzureHttpError:
            msg = 'Could not read logs from {}'.format(remote_log_location)
            self.log.exception(msg)
            # return error if needed
            if return_error:
                return msg 
开发者ID:apache,项目名称:airflow,代码行数:21,代码来源:wasb_task_handler.py

示例2: check_blob

# 需要导入模块: from azure import common [as 别名]
# 或者: from azure.common import AzureHttpError [as 别名]
def check_blob(self, blob, container_name=None):
        """
        Checks if a blob exists.

        Args:
            blob: `str`. Name of existing blob.
            container_name: `str`. Name of existing container.

        Returns:
            bool
        """
        if not container_name:
            container_name, _, blob = self.parse_wasbs_url(blob)
        try:
            return self.connection.get_blob_properties(
                container_name,
                blob
            )
        except AzureHttpError:
            return None 
开发者ID:polyaxon,项目名称:polystores,代码行数:22,代码来源:azure_store.py

示例3: download_file

# 需要导入模块: from azure import common [as 别名]
# 或者: from azure.common import AzureHttpError [as 别名]
def download_file(self, blob, local_path, container_name=None, use_basename=True):
        """
        Downloads a file from Google Cloud Storage.

        Args:
            blob: `str`. blob to download.
            local_path: `str`. the path to download to.
            container_name: `str`. the name of the container.
            use_basename: `bool`. whether or not to use the basename of the blob.
        """
        if not container_name:
            container_name, _, blob = self.parse_wasbs_url(blob)

        local_path = os.path.abspath(local_path)

        if use_basename:
            local_path = append_basename(local_path, blob)

        check_dirname_exists(local_path)

        try:
            self.connection.get_blob_to_path(container_name, blob, local_path)
        except AzureHttpError as e:
            raise PolyaxonStoresException(e) 
开发者ID:polyaxon,项目名称:polystores,代码行数:26,代码来源:azure_store.py

示例4: test_put_block_from_url_and_validate_content_md5

# 需要导入模块: from azure import common [as 别名]
# 或者: from azure.common import AzureHttpError [as 别名]
def test_put_block_from_url_and_validate_content_md5(self):
        # Arrange
        dest_blob_name = self.get_resource_name('destblob')
        src_md5 = _get_content_md5(self.source_blob_data)

        # Act part 1: put block from url with md5 validation
        self.bs.put_block_from_url(self.container_name, dest_blob_name, self.source_blob_url,
                                   block_id=1, source_content_md5=src_md5)

        # Assert block was staged
        block_list = self.bs.get_block_list(self.container_name, dest_blob_name, None, 'all')
        self.assertEqual(len(block_list.uncommitted_blocks), 1)
        self.assertEqual(len(block_list.committed_blocks), 0)

        # Act part 2: put block from url with wrong md5
        with self.assertRaises(AzureHttpError):
            self.bs.put_block_from_url(self.container_name, dest_blob_name, self.source_blob_url,
                                       block_id=2, source_content_md5=_get_content_md5(b"POTATO"))

        # Assert block was not staged
        block_list = self.bs.get_block_list(self.container_name, dest_blob_name, None, 'all')
        self.assertEqual(len(block_list.uncommitted_blocks), 1)
        self.assertEqual(len(block_list.committed_blocks), 0) 
开发者ID:Azure,项目名称:azure-storage-python,代码行数:25,代码来源:test_block_blob_sync_copy.py

示例5: test_update_page_from_url_and_validate_content_md5

# 需要导入模块: from azure import common [as 别名]
# 或者: from azure.common import AzureHttpError [as 别名]
def test_update_page_from_url_and_validate_content_md5(self):
        # Arrange
        src_md5 = _get_content_md5(self.source_blob_data)
        dest_blob_name = self.get_resource_name('destblob')
        self.bs.create_blob(self.container_name, dest_blob_name, SOURCE_BLOB_SIZE)

        # Act part 1: make update page from url calls with correct md5
        resp = self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                            end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                            source_range_start=0, source_content_md5=src_md5)

        self.assertIsNotNone(resp.etag)
        self.assertIsNotNone(resp.last_modified)

        # Assert the destination blob is constructed correctly
        blob = self.bs.get_blob_properties(self.container_name, dest_blob_name)
        self.assertBlobEqual(self.container_name, dest_blob_name, self.source_blob_data)
        self.assertEqual(blob.properties.etag, resp.etag)
        self.assertEqual(blob.properties.last_modified, resp.last_modified)

        # Act part 2: put block from url with wrong md5
        with self.assertRaises(AzureHttpError):
            self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                         end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                         source_range_start=0, source_content_md5=_get_content_md5(b"POTATO")) 
开发者ID:Azure,项目名称:azure-storage-python,代码行数:27,代码来源:test_page_blob.py

示例6: test_update_page_from_url_with_source_if_match

# 需要导入模块: from azure import common [as 别名]
# 或者: from azure.common import AzureHttpError [as 别名]
def test_update_page_from_url_with_source_if_match(self):
        # Arrange
        dest_blob_name = self.get_resource_name('destblob')
        self.bs.create_blob(self.container_name, dest_blob_name, SOURCE_BLOB_SIZE)
        src_blob_resource_properties = self.bs.get_blob_properties(self.container_name,
                                                                   self.source_blob_name).properties

        # Act part 1: make update page from url calls
        resp = self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                            end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                            source_range_start=0, source_if_match=src_blob_resource_properties.etag)
        self.assertIsNotNone(resp.etag)
        self.assertIsNotNone(resp.last_modified)

        # Assert the destination blob is constructed correctly
        blob = self.bs.get_blob_properties(self.container_name, dest_blob_name)
        self.assertBlobEqual(self.container_name, dest_blob_name, self.source_blob_data)
        self.assertEqual(blob.properties.etag, resp.etag)
        self.assertEqual(blob.properties.last_modified, resp.last_modified)

        # Act part 2: put block from url with failing condition
        with self.assertRaises(AzureHttpError):
            self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                         end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                         source_range_start=0, source_if_match='0x111111111111111') 
开发者ID:Azure,项目名称:azure-storage-python,代码行数:27,代码来源:test_page_blob.py

示例7: test_update_page_from_url_with_if_unmodified

# 需要导入模块: from azure import common [as 别名]
# 或者: from azure.common import AzureHttpError [as 别名]
def test_update_page_from_url_with_if_unmodified(self):
        # Arrange
        dest_blob_name = self.get_resource_name('destblob')
        resource_properties = self.bs.create_blob(self.container_name, dest_blob_name, SOURCE_BLOB_SIZE)

        # Act part 1: make update page from url calls
        resp = self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                            end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                            source_range_start=0, if_unmodified_since=resource_properties.last_modified)
        self.assertIsNotNone(resp.etag)
        self.assertIsNotNone(resp.last_modified)

        # Assert the destination blob is constructed correctly
        blob = self.bs.get_blob_properties(self.container_name, dest_blob_name)
        self.assertBlobEqual(self.container_name, dest_blob_name, self.source_blob_data)
        self.assertEqual(blob.properties.etag, resp.etag)
        self.assertEqual(blob.properties.last_modified, resp.last_modified)

        # Act part 2: put block from url with failing condition
        with self.assertRaises(AzureHttpError):
            self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                         end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                         source_range_start=0,
                                         if_unmodified_since=resource_properties.last_modified - timedelta(
                                             minutes=15)) 
开发者ID:Azure,项目名称:azure-storage-python,代码行数:27,代码来源:test_page_blob.py

示例8: test_update_page_from_url_with_if_match

# 需要导入模块: from azure import common [as 别名]
# 或者: from azure.common import AzureHttpError [as 别名]
def test_update_page_from_url_with_if_match(self):
        # Arrange
        dest_blob_name = self.get_resource_name('destblob')
        resource_properties = self.bs.create_blob(self.container_name, dest_blob_name, SOURCE_BLOB_SIZE)

        # Act part 1: make update page from url calls
        resp = self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                            end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                            source_range_start=0, if_match=resource_properties.etag)
        self.assertIsNotNone(resp.etag)
        self.assertIsNotNone(resp.last_modified)

        # Assert the destination blob is constructed correctly
        blob = self.bs.get_blob_properties(self.container_name, dest_blob_name)
        self.assertBlobEqual(self.container_name, dest_blob_name, self.source_blob_data)
        self.assertEqual(blob.properties.etag, resp.etag)
        self.assertEqual(blob.properties.last_modified, resp.last_modified)

        # Act part 2: put block from url with failing condition
        with self.assertRaises(AzureHttpError):
            self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                         end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                         source_range_start=0, if_match='0x111111111111111') 
开发者ID:Azure,项目名称:azure-storage-python,代码行数:25,代码来源:test_page_blob.py

示例9: test_update_page_from_url_with_if_none_match

# 需要导入模块: from azure import common [as 别名]
# 或者: from azure.common import AzureHttpError [as 别名]
def test_update_page_from_url_with_if_none_match(self):
        # Arrange
        dest_blob_name = self.get_resource_name('destblob')
        self.bs.create_blob(self.container_name, dest_blob_name, SOURCE_BLOB_SIZE)

        # Act part 1: make update page from url calls
        resp = self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                            end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                            source_range_start=0, if_none_match='0x111111111111111')
        self.assertIsNotNone(resp.etag)
        self.assertIsNotNone(resp.last_modified)

        # Assert the destination blob is constructed correctly
        blob = self.bs.get_blob_properties(self.container_name, dest_blob_name)
        self.assertBlobEqual(self.container_name, dest_blob_name, self.source_blob_data)
        self.assertEqual(blob.properties.etag, resp.etag)
        self.assertEqual(blob.properties.last_modified, resp.last_modified)

        # Act part 2: put block from url with failing condition
        with self.assertRaises(AzureHttpError):
            self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                         end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                         source_range_start=0, if_none_match=blob.properties.etag) 
开发者ID:Azure,项目名称:azure-storage-python,代码行数:25,代码来源:test_page_blob.py

示例10: test_update_page_from_url_with_sequence_number_lt

# 需要导入模块: from azure import common [as 别名]
# 或者: from azure.common import AzureHttpError [as 别名]
def test_update_page_from_url_with_sequence_number_lt(self):
        # Arrange
        start_sequence = 10
        dest_blob_name = self.get_resource_name('destblob')
        self.bs.create_blob(self.container_name, dest_blob_name, SOURCE_BLOB_SIZE, sequence_number=start_sequence)

        # Act part 1: make update page from url calls
        resp = self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                            end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                            source_range_start=0, if_sequence_number_lt=start_sequence + 1)
        self.assertIsNotNone(resp.etag)
        self.assertIsNotNone(resp.last_modified)

        # Assert the destination blob is constructed correctly
        blob = self.bs.get_blob_properties(self.container_name, dest_blob_name)
        self.assertBlobEqual(self.container_name, dest_blob_name, self.source_blob_data)
        self.assertEqual(blob.properties.etag, resp.etag)
        self.assertEqual(blob.properties.last_modified, resp.last_modified)

        # Act part 2: put block from url with failing condition
        with self.assertRaises(AzureHttpError):
            self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                         end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                         source_range_start=0, if_sequence_number_lt=start_sequence) 
开发者ID:Azure,项目名称:azure-storage-python,代码行数:26,代码来源:test_page_blob.py

示例11: test_update_page_from_url_with_sequence_number_eq

# 需要导入模块: from azure import common [as 别名]
# 或者: from azure.common import AzureHttpError [as 别名]
def test_update_page_from_url_with_sequence_number_eq(self):
        # Arrange
        start_sequence = 10
        dest_blob_name = self.get_resource_name('destblob')
        self.bs.create_blob(self.container_name, dest_blob_name, SOURCE_BLOB_SIZE, sequence_number=start_sequence)

        # Act part 1: make update page from url calls
        resp = self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                            end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                            source_range_start=0, if_sequence_number_eq=start_sequence)
        self.assertIsNotNone(resp.etag)
        self.assertIsNotNone(resp.last_modified)

        # Assert the destination blob is constructed correctly
        blob = self.bs.get_blob_properties(self.container_name, dest_blob_name)
        self.assertBlobEqual(self.container_name, dest_blob_name, self.source_blob_data)
        self.assertEqual(blob.properties.etag, resp.etag)
        self.assertEqual(blob.properties.last_modified, resp.last_modified)

        # Act part 2: put block from url with failing condition
        with self.assertRaises(AzureHttpError):
            self.bs.update_page_from_url(self.container_name, dest_blob_name, start_range=0,
                                         end_range=SOURCE_BLOB_SIZE - 1, copy_source_url=self.source_blob_url,
                                         source_range_start=0, if_sequence_number_eq=start_sequence + 1) 
开发者ID:Azure,项目名称:azure-storage-python,代码行数:26,代码来源:test_page_blob.py

示例12: test_put_block_list_invalid_block_id

# 需要导入模块: from azure import common [as 别名]
# 或者: from azure.common import AzureHttpError [as 别名]
def test_put_block_list_invalid_block_id(self):
        # Arrange
        blob_name = self._get_blob_reference()
        self.bs.put_block(self.container_name, blob_name, b'AAA', '1')
        self.bs.put_block(self.container_name, blob_name, b'BBB', '2')
        self.bs.put_block(self.container_name, blob_name, b'CCC', '3')

        # Act
        try:
            block_list = [ BlobBlock(id='1'), BlobBlock(id='2'), BlobBlock(id='4')]
            self.bs.put_block_list(self.container_name, blob_name, block_list)
            self.fail()
        except AzureHttpError as e:
            self.assertGreaterEqual(str(e).find('specified block list is invalid'), 0)

        # Assert 
开发者ID:Azure,项目名称:azure-storage-python,代码行数:18,代码来源:test_block_blob.py

示例13: test_put_block_list_with_if_modified_fail

# 需要导入模块: from azure import common [as 别名]
# 或者: from azure.common import AzureHttpError [as 别名]
def test_put_block_list_with_if_modified_fail(self):
        # Arrange
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'')
        self.bs.put_block(self.container_name, 'blob1', b'AAA', '1')
        self.bs.put_block(self.container_name, 'blob1', b'BBB', '2')
        self.bs.put_block(self.container_name, 'blob1', b'CCC', '3')
        test_datetime = (datetime.datetime.utcnow() +
                         datetime.timedelta(minutes=15))

        # Act
        with self.assertRaises(AzureHttpError):
            self.bs.put_block_list(
                self.container_name, 'blob1', [BlobBlock(id='1'), BlobBlock(id='2'), BlobBlock(id='3')],
                if_modified_since=test_datetime)

        # Assert 
开发者ID:Azure,项目名称:azure-storage-python,代码行数:19,代码来源:test_blob_access_conditions.py

示例14: test_put_block_list_with_if_unmodified_fail

# 需要导入模块: from azure import common [as 别名]
# 或者: from azure.common import AzureHttpError [as 别名]
def test_put_block_list_with_if_unmodified_fail(self):
        # Arrange
        self._create_container_and_block_blob(
            self.container_name, 'blob1', b'')
        self.bs.put_block(self.container_name, 'blob1', b'AAA', '1')
        self.bs.put_block(self.container_name, 'blob1', b'BBB', '2')
        self.bs.put_block(self.container_name, 'blob1', b'CCC', '3')
        test_datetime = (datetime.datetime.utcnow() -
                         datetime.timedelta(minutes=15))

        # Act
        with self.assertRaises(AzureHttpError):
            self.bs.put_block_list(
                self.container_name, 'blob1', [BlobBlock(id='1'), BlobBlock(id='2'), BlobBlock(id='3')],
                if_unmodified_since=test_datetime)

        # Assert 
开发者ID:Azure,项目名称:azure-storage-python,代码行数:19,代码来源:test_blob_access_conditions.py

示例15: test_get_page_ranges_iter_with_if_unmodified_fail

# 需要导入模块: from azure import common [as 别名]
# 或者: from azure.common import AzureHttpError [as 别名]
def test_get_page_ranges_iter_with_if_unmodified_fail(self):
        # Arrange
        self._create_container_and_page_blob(
            self.container_name, 'blob1', 2048)
        data = b'abcdefghijklmnop' * 32
        test_datetime = (datetime.datetime.utcnow() -
                         datetime.timedelta(minutes=15))
        self.pbs.update_page(self.container_name, 'blob1', data, 0, 511)
        self.pbs.update_page(self.container_name, 'blob1', data, 1024, 1535)

        # Act
        with self.assertRaises(AzureHttpError):
            self.pbs.get_page_ranges(self.container_name, 'blob1',
                                     if_unmodified_since=test_datetime)

        # Assert 
开发者ID:Azure,项目名称:azure-storage-python,代码行数:18,代码来源:test_blob_access_conditions.py


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