本文整理匯總了Python中scalarizr.libs.metaconf.Configuration.items方法的典型用法代碼示例。如果您正苦於以下問題:Python Configuration.items方法的具體用法?Python Configuration.items怎麽用?Python Configuration.items使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類scalarizr.libs.metaconf.Configuration
的用法示例。
在下文中一共展示了Configuration.items方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: load
# 需要導入模塊: from scalarizr.libs.metaconf import Configuration [as 別名]
# 或者: from scalarizr.libs.metaconf.Configuration import items [as 別名]
def load(self, preset_type):
'''
@rtype: Preset
@raise OSError: When cannot read preset file
@raise MetaconfError: When experience problems with preset file parsing
'''
self._logger.debug('Loading %s %s preset' % (preset_type, self.service_name))
ini = Configuration('ini')
ini.read(self._filename(preset_type))
return CnfPreset(ini.get('general/name'), dict(ini.items('settings/')))
示例2: __init__
# 需要導入模塊: from scalarizr.libs.metaconf import Configuration [as 別名]
# 或者: from scalarizr.libs.metaconf.Configuration import items [as 別名]
def __init__(self, manifest_path):
self._options = []
ini = Configuration('ini')
ini.read(manifest_path)
try:
self._defaults = dict(ini.items('__defaults__'))
except NoPathError:
self._defaults = dict()
for name in ini.sections("./"):
if name == '__defaults__':
continue
self._options.append(_OptionSpec.from_ini(ini, name, self._defaults))
示例3: download_and_restore
# 需要導入模塊: from scalarizr.libs.metaconf import Configuration [as 別名]
# 或者: from scalarizr.libs.metaconf.Configuration import items [as 別名]
def download_and_restore(self, volume, snapshot, tranzit_path):
# Load manifest
clear_queue(self._writer_queue)
clear_queue(self._download_queue)
self._download_finished.clear()
transfer = self._transfer_cls()
mnf_path = transfer.download(snapshot.path, tranzit_path)
mnf = Configuration('ini')
mnf.read(mnf_path)
volume.fs_created = False
volume.mkfs(snapshot.fstype)
remote_path = os.path.dirname(snapshot.path)
# Get links with md5 sums
links = [(os.path.join(remote_path, chunk[0]), chunk[1]) for chunk in mnf.items('chunks')]
links.sort()
# Download 2 first chunks
for link in links[:2]:
transfer.download(link[0], tranzit_path)
chunk_path = os.path.join(tranzit_path, os.path.basename(link[0]))
if self._md5sum(chunk_path) != link[1]:
raise Exception("md5sum of chunk %s is not correct." % chunk_path)
self._writer_queue.put(chunk_path)
if hasattr(snapshot, 'snap_strategy') and snapshot.snap_strategy == 'data':
restore_strategy = DataRestoreStrategy(self._logger)
else:
restore_strategy = DeviceRestoreStrategy(self._logger)
writer = threading.Thread(target=restore_strategy.restore, name='writer',
args=(self._writer_queue, volume, self._download_finished))
writer.start()
# Add remaining files to download queue
for link in links[2:]:
self._download_queue.put(link)
downloader = threading.Thread(name="Downloader", target=self._downloader,
args=(tranzit_path,))
downloader.start()
downloader.join()
writer.join()