本文整理汇总了Python中portalpy.Portal.item_datad方法的典型用法代码示例。如果您正苦于以下问题:Python Portal.item_datad方法的具体用法?Python Portal.item_datad怎么用?Python Portal.item_datad使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类portalpy.Portal
的用法示例。
在下文中一共展示了Portal.item_datad方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import item_datad [as 别名]
def main():
exit_err_code = 1
# Print/get script arguments
results = print_args()
if not results:
sys.exit(exit_err_code)
portal_address, adminuser, password = results
total_success = True
title_break_count = 100
section_break_count = 75
search_query = None
print '=' * title_break_count
print 'Validate Hosted Service Sources'
print '=' * title_break_count
source_items = []
hosted_items = []
root_folder_path = None
root_folder_path = tempfile.mkdtemp()
print 'Temporary directory: {}'.format(root_folder_path)
orig_dir = os.getcwd()
try:
portal = Portal(portal_address, adminuser, password)
items = portal.search()
# ---------------------------------------------------------------------
# Get info about hosted service source items
# (currently service definitions)
# ---------------------------------------------------------------------
for item in items:
if item['type'] == 'Service Definition':
print '\nDownloading and extracting Service Definition item {}'.format(item['id'])
# Download .sd file
download_root_path = os.path.join(root_folder_path, item['id'])
os.mkdir(download_root_path)
download_path = portal.item_datad(item['id'], download_root_path)
# Extract serviceconfiguration.json file from downloaded .sd file
file_name = 'serviceconfiguration.json'
extract_path = download_path.replace('.sd', '')
#print extract_path
os.mkdir(extract_path)
err_stat = extractFromSDFile(download_path, extract_path, file_name)
print 'Extract status: {}'.format(err_stat)
# Open extract .json file
file_path = findFilePath(extract_path, file_name)
os.chdir(os.path.dirname(file_path))
service_config = json.load(open(file_name))
# [{id: val, owner: val, title: val, type: val
# service_config: {stuff from .json file}}]
d = {
'id': item['id'],
'owner': item['owner'],
'title': item['title'],
'type': item['type'],
'service_config': service_config
}
source_items.append(d)
# ---------------------------------------------------------------------
# Get info about hosted service items
# ---------------------------------------------------------------------
print '\nDetermine what hosted services exist...'
h_service_items = get_hosted_service_items(portal, items)
for item in h_service_items:
d = {
'id': item['id'],
'owner': item['owner'],
'title': item['title'],
'type': item['type'],
'url': item['url']
}
hosted_items.append(d)
# ---------------------------------------------------------------------
# For each hosted service find the associated source item
# ---------------------------------------------------------------------
print '=' * section_break_count
print '\nDetermine which source items are associated with each hosted service...'
print '=' * section_break_count
num_hosted_no_match = 0
num_hosted_match = 0
num_hosted_mismatch_owner = 0
write_str = "\tid: {:<34}owner: {:<20}type: {:<25}service: {:<50}\n"
for hosted_d in hosted_items:
found = False
#.........这里部分代码省略.........