Guest User

Untitled

a guest
Apr 4th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. #-------------------------------------------------------------
  2. # Boilerplate connection / authentication
  3. #-------------------------------------------------------------
  4. import arcgis
  5. from arcgis.gis import GIS
  6.  
  7. # Login credentials
  8. url = "<url to agol or portal>"
  9. username = "<user name>"
  10. password = "<password>"
  11.  
  12. # Make a connection to the portal
  13. gis = GIS(url=url, username=username, password=password)
  14.  
  15.  
  16. #-------------------------------------------------------------
  17. # Print portal members and group membership
  18. #-------------------------------------------------------------
  19. # Query the portal for all org users
  20. portal_users = gis.users.search(query="*")
  21.  
  22. for user in portal_users:
  23. user_details = gis.users.get(user.username)
  24.  
  25. # Get user details from response
  26. user_name = user_details.username
  27. user_full_name = user_details.fullName
  28. groups = user_details.groups
  29. group_names = [i.title for i in groups]
  30. group_names.sort()
  31.  
  32. # Format response for user
  33. resp = user_full_name + "(" + user_name + ")" + "\n"
  34. resp += "Groups: " + ", ".join(group_names) + "\n"
  35. resp += "\n"
  36.  
  37. # Print response
  38. print(resp)
  39.  
  40.  
  41. #-------------------------------------------------------------
  42. # Print item properties
  43. #-------------------------------------------------------------
  44. itemid = "af7568d8579048f7b42e534891824029"
  45. item_object = gis.content.get(itemid)
  46. for i in item_object:
  47. print(i, ":", item_object[i])
  48.  
  49.  
  50. #-------------------------------------------------------------
  51. # Print item size
  52. # (Helpful for determining size of tile layer
  53. #-------------------------------------------------------------
  54. itemid = "acb03aa4b0a04c0a831917b64ef4a860"
  55. i = gis.content.get(itemid)
  56. s = i.size
  57. mb = round(s / 1048576, 3)
  58. gb = round(s / 1073741824, 3)
  59. print("{0} is {1} MB, {2} GB".format(i.title, mb, gb))
Add Comment
Please, Sign In to add comment