I'm trying to learn the ArcGIS API for Python and get used to this pattern of iterating over lists to get the resource you want. I just don't see in the documentation how you would use the list method to list the servers from a ServerManager object and select one of them specifically. If I had multiple servers, how would I use the URL to select a server from the list. I don't like the answer just list them in a Jupyter notebook and choose which one you need. I'm going to be putting this in a script and I also don't like the idea of just hardcoding the index either. I don't trust that the order will always be the same in the future.
I can see all the arguments for the class constructor, but I don't see much in general for class attributes.
Solved! Go to Solution.
did you consider to pass in the server URL you're after to select out the server, e.g:
def get_server(url)
portal_url="https://spt.gis.com/arcgis"
portal_username="portaladmin"
portal_password="adminpassword"
gis = GIS(portal_url, portal_username, portal_password,verify_cert=False)
my_servers =gis.admin.servers.list()
for server in my_servers:
print(server.url)
if server.url==url:
print("hi,we're here")
did you consider to pass in the server URL you're after to select out the server, e.g:
def get_server(url)
portal_url="https://spt.gis.com/arcgis"
portal_username="portaladmin"
portal_password="adminpassword"
gis = GIS(portal_url, portal_username, portal_password,verify_cert=False)
my_servers =gis.admin.servers.list()
for server in my_servers:
print(server.url)
if server.url==url:
print("hi,we're here")
Yes, I was thinking of that but the documentation only shows constructor arguments, not available properties. I printed the __dict__ property of the Server objects and _url was listed, but I did not want to use a private variable. I do see how url is a property if you just try to access it. It would be nice if the documentation was more thorough like the JavaScript API. I prefer having the public attributes described.
I normally will use **dir(object)** rather than __dict__
Thanks, I will add that one to my toolbox. I can see the url attribute now.