<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Start Stop Services Errors in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338770#M9161</link>
    <description>&lt;P&gt;For standalone servers, you want to be using the&amp;nbsp;&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.server.html" target="_blank" rel="noopener"&gt;arcgis.gis.server module&lt;/A&gt;&amp;nbsp;instead of arcgis.gis.admin. Update your code to use the correct module and it should work for the standalone servers.&lt;/P&gt;</description>
    <pubDate>Tue, 17 Oct 2023 18:20:26 GMT</pubDate>
    <dc:creator>EarlMedina</dc:creator>
    <dc:date>2023-10-17T18:20:26Z</dc:date>
    <item>
      <title>Start Stop Services Errors</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338628#M9156</link>
      <description>&lt;P&gt;I am having issues with getting a list of Services PRIOR to stopping and starting them.&amp;nbsp; I am trying to get this info two different ways and getting errors on both...&amp;nbsp;&lt;/P&gt;&lt;P&gt;One of the examples is coming from here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en-us/knowledge-base/how-to-stop-gis-services-using-arcgis-api-for-python-000019994" target="_blank" rel="noopener"&gt;https://support.esri.com/en-us/knowledge-base/how-to-stop-gis-services-using-arcgis-api-for-python-000019994&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Any ideas what I am doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    from arcgis.gis import GIS
    import arcgis.gis.admin
    
    nonProdPortal = "https://xxxx.xxx.gov/portal"
    loginName = "xxxxx"
    loginPass = "xxxxx"

    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")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\server\_common\_base.py", line 93, in __getattr__&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;"'%s' object has no attribute '%s'" % (type(self).__name__, name)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;AttributeError: 'Server' object has no attribute 'services'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    from arcgis import gis

    nonProdPortal = "https://xxxxx.gov/portal"
    loginName = "xxxx"
    loginPass = "xxxx"

    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)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\server\_common\_base.py", line 93, in __getattr__&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;"'%s' object has no attribute '%s'" % (type(self).__name__, name)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;AttributeError: 'Server' object has no attribute 'services'&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 15:39:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338628#M9156</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-17T15:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Start Stop Services Errors</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338706#M9158</link>
      <description>&lt;P&gt;Is the account you are logging in with an administrator account?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 16:22:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338706#M9158</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-10-17T16:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: Start Stop Services Errors</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338707#M9159</link>
      <description>&lt;P&gt;OK Weird thing.... I printed my servers and noticed that the main server does not have HTTPS and the hosted server does have HTTPS&lt;/P&gt;&lt;P&gt;I changed my code to point the the hosted Feature Server because that has HTTPS in the name...and the code runs...&amp;nbsp;&lt;/P&gt;&lt;P&gt;Changed the index to point to the second server:&amp;nbsp;&amp;nbsp;server1 = gis_servers[1]&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;&lt;STRONG&gt;Is that the reason or does this code only run on a Hosted Server?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    gis = GIS(nonProdPortal, loginName, loginPass, verify_cert=False)
    gis_servers = gis.admin.servers.list()
    print(gis_servers)
    print("")
    
    server1 = gis_servers[1]
    print(server1)
    
    validate = gis.admin.servers.validate()
    print("Is the server valid? " + str(validate))

    foldersList = server1.services.folders
    print(foldersList)

    print("")
    print("-----------")
    print("")
    
    servicesList = server1.services.list()
    print(servicesList)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Results:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;[&amp;lt;Server at http://xxx.xxxxx.gov/env/admin&amp;gt;, &amp;lt;Server at https://xxxx.xxxx.gov/hosting/admin&amp;gt;]

&amp;lt;Server at https://xxxxx.xxxxx.gov/hosting/admin&amp;gt;

Is the server valid? True

['Hosted', 'System', 'Utilities', '/']

-----------
[&amp;lt;Service at https://xxxl.xx.xxxx.gov/hosting/admin/services/bmpReportTool.GPServer&amp;gt;,
&amp;lt;Service at https://xxxl.xx.xxxx.gov/hosting/admin/services/ImportCurveData.GPServer&amp;gt;, 
&amp;lt;Service at https://xxxl.xx.xxxx.gov/hosting/admin/services/npdesReportTool.GPServer&amp;gt;,
&amp;lt;Service at https://xxxl.xx.xxxx.gov/hosting/admin/services/SWPPP_Annual_Dev.MapServer&amp;gt;, 
&amp;lt;Service at https://xxxl.xx.xxxx.gov/hosting/admin/services/SWPPP_Monthly_Dev.MapServer&amp;gt;]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 16:29:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338707#M9159</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-17T16:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Start Stop Services Errors</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338712#M9160</link>
      <description>&lt;P&gt;If you see my last post... I got a list of servers and say one had http and one https .. I changed my code to point the second index and it works fine... but this is pointing to a hosted server and I want my non prod portal server.&amp;nbsp; Its using the same credentials...&lt;/P&gt;&lt;P&gt;I dont think this is a system admin but its got elevated permissions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error does not seem to be permissions... its telling me that the http server that services is not in the server object...&amp;nbsp;&lt;/P&gt;&lt;P&gt;But then it runs on the hosted server fine.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 16:32:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338712#M9160</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-17T16:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: Start Stop Services Errors</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338770#M9161</link>
      <description>&lt;P&gt;For standalone servers, you want to be using the&amp;nbsp;&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.server.html" target="_blank" rel="noopener"&gt;arcgis.gis.server module&lt;/A&gt;&amp;nbsp;instead of arcgis.gis.admin. Update your code to use the correct module and it should work for the standalone servers.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 18:20:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338770#M9161</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-10-17T18:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: Start Stop Services Errors</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338780#M9162</link>
      <description>&lt;P&gt;Tells me Server not defined&lt;/P&gt;&lt;P&gt;I updated my IMPORT to arcgis.gis.server&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;from arcgis.gis import GIS
import arcgis.gis.server

def listServices():
    loginName = "xxxx"
    loginPass = "xxxxx"

    server_base_url = "https://xxxxx.gov/portal/admin/"

    gis_server = Server(url=f"{server_base_url}/web_adaptor/admin",
                        token_url=f"{server_base_url}/web_adaptor/tokens/generateToken",
                        username=loginName,
                        password=loginPass)

    foldersList = gis_server.services.folders
    print(foldersList)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 18:57:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338780#M9162</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-17T18:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Start Stop Services Errors</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338813#M9164</link>
      <description>&lt;P&gt;OK I think I made progress...&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the serviceList2 returns a list object? but I am just looking for the Service Name... how do I get that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Returned:&lt;/P&gt;&lt;P&gt;&amp;lt;Service at &lt;A href="https://community.esri.com/" target="_blank"&gt;https://xxx.cov.xxx.gov:6443/arcgis/admin/services/DEQ_DEV/VDEQ_Petro_Release_DEV.MapServer&amp;gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Looking for&lt;/P&gt;&lt;P&gt;VDEQ_Petro_Release_DEV&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;from arcgis.gis import GIS
import arcgis.gis.server

def listServices():
    nonProdPortal = "https://xxx.gov/portal"
    loginName = "xxx"
    loginPass = "xxxxx"

    gis = GIS(nonProdPortal, loginName, loginPass, verify_cert=False)
    gis_servers = gis.admin.servers.list()

    server1 = gis_servers[0]
    print(server1)

    servicesList2 = server1.services.list(folder='DEQ_DEV')[0]
    print(servicesList2)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 19:26:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338813#M9164</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-17T19:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Start Stop Services Errors</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338834#M9165</link>
      <description>&lt;P&gt;The name you can find in the service iteminformation:&lt;/P&gt;&lt;PRE&gt;service.iteminformation.properties["name"]&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 19:55:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338834#M9165</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-10-17T19:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Start Stop Services Errors</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338841#M9166</link>
      <description>&lt;P&gt;I got it... leaving some junk in here that is commented out that still does stuff...&lt;/P&gt;&lt;P&gt;BUT basically I can point to a Stand Alone Server and:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;List Folder Names&lt;/LI&gt;&lt;LI&gt;List Services in those folder names&lt;/LI&gt;&lt;LI&gt;specific a specific folder and turn on and off services in that folder...&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;It would be nice to read into that LIST OBject and get the specific service name and use that to start and stop services... Where I could say IF the service name = XXX stop it and leave the others in the folder alone...&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have not figure out how to do that yet... as a list object is being sent back to me.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;EDIT: While I was posting&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/86309"&gt;@EarlMedina&lt;/a&gt;&amp;nbsp; posted the solution to get the name... I UPDATED the code below to print that out but did not build the IF THEN yet...&amp;nbsp;&lt;/P&gt;&lt;P&gt;THANKS&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/86309"&gt;@EarlMedina&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;from arcgis.gis import GIS
import arcgis.gis.server

def listServices():
    nonProdPortal = "https://xxx.xxxx.xxx.gov/portal"
    loginName = "xxxx"
    loginPass = "xxxx"

    gis = GIS(nonProdPortal, loginName, loginPass, verify_cert=False)
    gis_servers = gis.admin.servers.list()
    print(gis_servers)
    print("")

    server1 = gis_servers[0]
    print(server1)
    print("")

    foldersList = server1.services.folders
    print(foldersList)

    # LIST FOLDERS and THEN ALL THE SERVICES IN THOSE FOLDERS
    #for folder in foldersList:
    #    foldername = folder
    #    print(foldername)
    #    servicesList = server1.services.list(folder=foldername)
    #    for servicename in servicesList:
    #        servicenameValue = servicename
    #        print("---" + str(servicenameValue))
    
    servicesList2 = server1.services.list(folder='DEQ_DEV')
    for service in servicesList2:
        
        # GIVE ME THE SERVICE NAME
        service_name = service.iteminformation.properties["name"]
        print(service_name)

        print(service)    
        status = service.status
        print(status)
        #service.stop()
        #service.start()
        status = service.status
        print(status)    
    
if __name__ == '__main__':
    listServices()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 20:04:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338841#M9166</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-17T20:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: Start Stop Services Errors</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338847#M9167</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/86309"&gt;@EarlMedina&lt;/a&gt;&amp;nbsp; do I mark your replay above regarding&amp;nbsp;import arcgis.gis.server module as the solution and leave my full working code below as a reply?&amp;nbsp; Want to make sure you get credit for this as you steered me in the correct direction ????&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 20:06:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338847#M9167</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2023-10-17T20:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: Start Stop Services Errors</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338850#M9168</link>
      <description>&lt;P&gt;Oh, it doesn't matter. Whatever is most useful to anyone out there. I'm just here to help out.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 20:08:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1338850#M9168</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-10-17T20:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Start Stop Services Errors</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1568657#M10967</link>
      <description>&lt;P&gt;These two articles helped me accomplish stopping and starting services programatically:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/latest/guide/managing-your-gis-servers/" target="_blank" rel="nofollow noopener noreferrer"&gt;https://developers.arcgis.com/python/latest/guide/managing-your-gis-servers/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en-us/knowledge-base/how-to-stop-gis-services-using-arcgis-api-for-python-000019994" target="_blank" rel="nofollow noopener noreferrer"&gt;https://support.esri.com/en-us/knowledge-base/how-to-stop-gis-services-using-arcgis-api-for-python-0...&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;A href="https://developers.arcgis.com/rest/enterprise-administration/enterprise/service-status/" target="_blank"&gt;https://developers.arcgis.com/rest/enterprise-administration/enterprise/service-status/&lt;/A&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 14 Dec 2024 08:04:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/start-stop-services-errors/m-p/1568657#M10967</guid>
      <dc:creator>AndresCastillo</dc:creator>
      <dc:date>2024-12-14T08:04:08Z</dc:date>
    </item>
  </channel>
</rss>

