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