I am having issues with getting a list of Services PRIOR to stopping and starting them. I am trying to get this info two different ways and getting errors on both...
One of the examples is coming from here:
https://support.esri.com/en-us/knowledge-base/how-to-stop-gis-services-using-arcgis-api-for-python-000019994
Any ideas what I am doing wrong?
from arcgis.gis import GIS
import arcgis.gis.admin
nonProdPortal = "https://xyz.xyz.gov/portal"
loginName = "xyz"
loginPass = "xyz"
gis = GIS(nonProdPortal, loginName, loginPass, verify_cert=False)
gis_servers = gis.admin.servers.list()
#To stop specific service(s)
for server in gis_servers:
for service in server.services.list():
#print(service.properties.serviceName)
if service.properties.serviceName == "TMPD_AGO":
#service.stop()
print("Stopping TMPD_AGO")
ERROR:
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\server\_common\_base.py", line 93, in __getattr__
"'%s' object has no attribute '%s'" % (type(self).__name__, name)
AttributeError: 'Server' object has no attribute 'services'
from arcgis import gis
nonProdPortal = "https://xyz.gov/portal"
loginName = "xyz"
loginPass = "xyz"
mygis = gis.GIS(nonProdPortal, username=loginName, password=loginPass, verify_cert=False)
#mygis = GIS(nonProdPortal, loginName, loginPass, verify_cert=False)
servers = mygis.admin.servers.list()
one_server = servers[0]
services_on_that_server = one_server.services.list()
one_of_those_services = services_on_that_server[0]
# provided your service is running to begin with
print(one_of_those_services.status)
ERROR:
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\server\_common\_base.py", line 93, in __getattr__
"'%s' object has no attribute '%s'" % (type(self).__name__, name)
AttributeError: 'Server' object has no attribute 'services'