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


Python BlobService.get_blob_metadata方法代码示例

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


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

示例1: AzureBlobService

# 需要导入模块: from azure.storage import BlobService [as 别名]
# 或者: from azure.storage.BlobService import get_blob_metadata [as 别名]
class AzureBlobService():
	
	def __init__(self, logger, account_name, account_key):
		self.logger = logger
		self.blob_service = BlobService(account_name=account_name, account_key=account_key)
		self.pbar = None

	def azure_sync(self, root_path, container, check=False):
		return_code = 0

		if not os.path.exists(root_path):
			self.logger.error("Error in sync file %s to azure. Details: No such file or directory" % (root_path))
			return_code = 1
		else:
			dt_start = datetime.now()
			self.logger.info("Syncing files from %s to azure container %s" % (root_path, container))
			for root, dirs, files in os.walk(root_path, topdown=False):
				for name in files:
					blob_metadata = {}
					path = os.path.join(root, name)

					mtime = str(os.path.getmtime(path))

					try:
						self.logger.debug("file: %s - Checking file modification time with azure API" % (path))
						blob_metadata = self.blob_service.get_blob_metadata(container, path)
					except Exception, e:
						if type(e).__name__ != 'WindowsAzureMissingResourceError':
							self.logger.error("file: %s - Can't check file modification time with azure API. Details: %s - %s" % (path, type(e).__name__, str(e)))
							return_code = return_code + 1
							continue
						else:
							pass

				if ('x-ms-meta-mtime' not in blob_metadata) or (blob_metadata['x-ms-meta-mtime'] != mtime):
						return_code = return_code + self.azure_send(container, path, mtime)

		dt_finish = datetime.now()
		dt_elapsed = dt_finish - dt_start

		if return_code == 0:
			self.logger.info("Sync files from %s to azure finished successfully. Time to sync: %s" % (root_path, dt_elapsed))
		else:
			self.logger.error("Sync files from %s to azure finished with %i errors. Time to sync: %s" % (root_path, return_code, dt_elapsed))

		return return_code
开发者ID:fehraraujo,项目名称:principal,代码行数:48,代码来源:windows_azure.py


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