Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-------------------------------------------------------------
- # Boilerplate connection / authentication
- #-------------------------------------------------------------
- import arcgis
- from arcgis.gis import GIS
- # Login credentials
- url = "<url to agol or portal>"
- username = "<user name>"
- password = "<password>"
- # Make a connection to the portal
- gis = GIS(url=url, username=username, password=password)
- #-------------------------------------------------------------
- # Print portal members and group membership
- #-------------------------------------------------------------
- # Query the portal for all org users
- portal_users = gis.users.search(query="*")
- for user in portal_users:
- user_details = gis.users.get(user.username)
- # Get user details from response
- user_name = user_details.username
- user_full_name = user_details.fullName
- groups = user_details.groups
- group_names = [i.title for i in groups]
- group_names.sort()
- # Format response for user
- resp = user_full_name + "(" + user_name + ")" + "\n"
- resp += "Groups: " + ", ".join(group_names) + "\n"
- resp += "\n"
- # Print response
- print(resp)
- #-------------------------------------------------------------
- # Print item properties
- #-------------------------------------------------------------
- itemid = "af7568d8579048f7b42e534891824029"
- item_object = gis.content.get(itemid)
- for i in item_object:
- print(i, ":", item_object[i])
- #-------------------------------------------------------------
- # Print item size
- # (Helpful for determining size of tile layer
- #-------------------------------------------------------------
- itemid = "acb03aa4b0a04c0a831917b64ef4a860"
- i = gis.content.get(itemid)
- s = i.size
- mb = round(s / 1048576, 3)
- gb = round(s / 1073741824, 3)
- print("{0} is {1} MB, {2} GB".format(i.title, mb, gb))
Add Comment
Please, Sign In to add comment