本文整理汇总了Python中portalpy.Portal.properties方法的典型用法代码示例。如果您正苦于以下问题:Python Portal.properties方法的具体用法?Python Portal.properties怎么用?Python Portal.properties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类portalpy.Portal
的用法示例。
在下文中一共展示了Portal.properties方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: portal_info_plus
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import properties [as 别名]
def portal_info_plus():
portal = Portal('http://portaldev.esri.com')
print portal.info()
pprint(portal.properties())
pprint(portal.languages())
pprint(portal.regions())
pprint(portal.basemaps(['title']))
pprint(portal.color_sets(['title']))
pprint(portal.featured_items(['title']))
pprint(portal.featured_items_homepage(['title']))
pprint(portal.feature_collection_templates(['title']))
pprint(portal.symbol_sets(['title']))
pprint(portal.gallery_templates(['title']))
pprint(portal.webmap_templates(['title']))
示例2: extract_portal
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import properties [as 别名]
def extract_portal(portaladdress,contentpath,adminuser,adminpassword, specifiedUsers):
'''Extract Portal info and content for all specified users'''
specifiedUsers = specifiedUsers.lower()
excludeUsersList = []
includeUsersList = []
#if first character is a minus, then the "specifiedUsers" variable
# contains a comma delimited string of the users to exclude from the extract
if len(specifiedUsers) > 0:
if specifiedUsers.find("-") == 0:
specifiedUsers = specifiedUsers.replace("-","",1)
excludeUsersList = specifiedUsers.split(",")
else:
includeUsersList = specifiedUsers.split(",")
# Create root output folder if it doesn't exist.
if not os.path.exists(contentpath):
os.makedirs(contentpath)
os.chdir(contentpath)
#Make Admin connection to portal and retrieve portal info
portaladmin = Portal(portaladdress, adminuser, adminpassword)
# ------------------------------------------------------------------------
# Extract Portal Properties
# ------------------------------------------------------------------------
portal_properties = portaladmin.properties()
print "\n- Extracting portal info ..."
json.dump(portal_properties, open('portal_properties.json','w'))
#Get portal featured items
# get a list of portal resources
resources = portaladmin.resources(portal_properties['id'])
json.dump(resources,open('resources.json','w'))
# ------------------------------------------------------------------------
# Extract users, groups and items
# ------------------------------------------------------------------------
print "\n- Extracting users, groups and items ..."
usersList = []
usersListAllNames = []
# Get list of users on the source portal
usersListAllNames_temp = portaladmin.users()
# Remove any esri_ accounts from the list
for u in usersListAllNames_temp:
if not u["username"].startswith("esri_"):
usersListAllNames.append(u)
# Create list of users that we don't want to extract content for.
# NOTE: specify user names in lowercase.
userExcludeList = ["admin", "system_publisher", "administrator"]
# If user has specified users to exclude from extract then add these
# users to the exclude list
if len(excludeUsersList) > 0:
userExcludeList.extend(excludeUsersList)
# Create output file to store username and fullname properties
userfile = open(os.path.join(contentpath,'userfile.txt'),'w')
# If only specific users should be extracted
# then only keep those users in the user information dictionary
if len(includeUsersList) > 0:
for u in usersListAllNames:
userName = u["username"]
if userName.lower() in includeUsersList:
usersList.append(u)
else:
usersList = usersListAllNames
userfile.write("SourceUserName,TargetUserName,TargetPassword\n")
for u in usersList:
userName = u["username"]
if userName.lower() not in userExcludeList:
users[str(userName)] = None
userfile.write(userName + "," + userName + ",MyDefault4Password!" + "\n")
userfile.close()
for username in users.keys():
# Create output folder if it doesn't exist
extractpath = os.path.join(contentpath, username)
if not os.path.exists(extractpath):
os.makedirs(extractpath)
print "\n" + sectionBreak
print "Extracting content for user: " + username
# Dump user info to json file
userinfo = portaladmin.user(username)
filepath = os.path.join(extractpath, 'userinfo.json')
json.dump(userinfo, open(filepath,'w'))
# Extract folders for user
#.........这里部分代码省略.........
示例3: publish_portal
# 需要导入模块: from portalpy import Portal [as 别名]
# 或者: from portalpy.Portal import properties [as 别名]
def publish_portal(portaladdress,contentpath,adminuser,adminpassword, users, hostname_map, specified_groups, id_mapping_file):
os.chdir(contentpath)
portal_properties = json.load(open("portal_properties.json"))
portaladmin = Portal(portaladdress, adminuser, adminpassword)
print_script_header(portaladmin, portal_processing, users, specified_groups)
# Create Portal log folder for this portal
portalLogPath = os.path.join(contentpath, portalLogFolder, get_servername_from_url(portaladmin.url))
makeFolder(portalLogPath)
# ------------------------------------------------------------------------
# Get info about the groups on disk to filter items based on group membership
# ------------------------------------------------------------------------
# Get the groups on disk
grps_on_disk = get_groups_on_disk(contentpath)
# Validate that each specified group is valid
if specified_groups:
invalid_specified_groups = []
for specified_group in specified_groups:
found = False
for grp in grps_on_disk.itervalues():
if specified_group == grp:
found = True
if not found:
invalid_specified_groups.append(specified_group)
if len(invalid_specified_groups) > 0:
print '\n***ERROR: the following specified groups do not exist; NOTE: group owner and group title must match exactly including case:\n'
print invalid_specified_groups
return
# ------------------------------------------------------------------------
# Create users
# ------------------------------------------------------------------------
print titleBreak
print 'Create users...\n'
# Only create users if this is not an online organization
if portaladmin.properties()['id'] == '0123456789ABCDEF': # All portals have this id.
for username, userinfo in users.iteritems():
create_user(portaladmin, contentpath, userinfo)
else:
print '\tThis is an online organization. Users must already have been created.'
# ------------------------------------------------------------------------
# Create user folders
# ------------------------------------------------------------------------
print '\n'+ titleBreak
print 'Create user folders...\n'
for username, userinfo in users.iteritems():
print '\nUser: ' + userinfo['target_username']
create_user_folders(portaladmin, contentpath, userinfo)
# ------------------------------------------------------------------------
# Create groups and add users to groups
# ------------------------------------------------------------------------
print "\n" + titleBreak
print "Creating groups ...\n"
oldGrpID_newGrpID = {}
for username, userinfo in users.iteritems():
newGroups = publish_user_groups(portaladmin, contentpath, userinfo, users)
for key,val in newGroups.iteritems():
oldGrpID_newGrpID[key] = {'id': val}
# ------------------------------------------------------------------------
# Publish Items and Update their sharing info
# ------------------------------------------------------------------------
print "\n" + titleBreak
print "Publishing items and setting sharing ..."
print titleBreak
for username, userinfo in users.iteritems():
username = userinfo['target_username']
password = userinfo['target_password']
userfoldername = userinfo['username']
# ---------------------------------------
# Publish all the users' items
# ---------------------------------------
usercontentpath = os.path.join(contentpath, userfoldername)
newItems, origItemSourceIDs = publish_user_items(portaladmin, username, usercontentpath, source_hostname,
new_hostname, new_port, specified_groups, id_mapping_file, grps_on_disk)
# Dump info about new items to JSON to use for resetting IDs of related items
dump_newItem_info(newItems, origItemSourceIDs, os.path.join(portalLogPath, username))
# ---------------------------------------
# Share the users' items with the
# appropriate groups
# ---------------------------------------
userItemsPath = os.path.join(contentpath, userfoldername, "items")
share_items(portaladmin, userItemsPath, newItems, origItemSourceIDs, originGroupToDestGroups)
#.........这里部分代码省略.........