<?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: Stop start locator service with specific word in name in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/stop-start-locator-service-with-specific-word-in/m-p/1084376#M61899</link>
    <description>&lt;P&gt;Thanks, I'll change the variable.&lt;/P&gt;&lt;P&gt;The code is correct, all our public geocode services are in the root server folder.&lt;/P&gt;</description>
    <pubDate>Fri, 30 Jul 2021 12:35:08 GMT</pubDate>
    <dc:creator>AliciaShyu</dc:creator>
    <dc:date>2021-07-30T12:35:08Z</dc:date>
    <item>
      <title>Stop start locator service with specific word in name</title>
      <link>https://community.esri.com/t5/python-questions/stop-start-locator-service-with-specific-word-in/m-p/1084048#M61886</link>
      <description>&lt;P&gt;I have the following script that's supposed to stop locator services with a specific word in the name.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for server in gis_server:
    if (server.url == 'https://arcgisserver/admin'):
        for service in server.services.list():
           if service.properties.type == 'GeocodeServer' and "parcel" in service.properties.serviceName:
                service.stop()
                print(service.properties["serviceName"]  + ' stopped')&lt;/LI-CODE&gt;&lt;P&gt;Line #4 doesn't work, I don't get any errors but it doesn't stop the locator services that have the word "Parcel" in the name.&lt;/P&gt;&lt;P&gt;I have 3 locator services with the word "parcel":&lt;/P&gt;&lt;P&gt;- Composite_Parcel&lt;/P&gt;&lt;P&gt;- RegionalParcelLocator&lt;/P&gt;&lt;P&gt;- ABCCompositeParcel&lt;/P&gt;&lt;P&gt;How should I update line 4 to only stop the locator services that have "parcel" in the name?&lt;/P&gt;&lt;P&gt;TIA&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 16:12:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stop-start-locator-service-with-specific-word-in/m-p/1084048#M61886</guid>
      <dc:creator>AliciaShyu</dc:creator>
      <dc:date>2021-07-29T16:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Stop start locator service with specific word in name</title>
      <link>https://community.esri.com/t5/python-questions/stop-start-locator-service-with-specific-word-in/m-p/1084097#M61888</link>
      <description>&lt;P&gt;Is this your entire script to stop locator (geocode) services?&amp;nbsp; If not, can you provide more of the script?&lt;/P&gt;&lt;P&gt;Are these ArcMap based locators or Pro based locators?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 17:34:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stop-start-locator-service-with-specific-word-in/m-p/1084097#M61888</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2021-07-29T17:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Stop start locator service with specific word in name</title>
      <link>https://community.esri.com/t5/python-questions/stop-start-locator-service-with-specific-word-in/m-p/1084105#M61889</link>
      <description>&lt;P&gt;The script stop locator services, rebuilds the locators and start services. We get new parcel every two weeks and need to update the locators to find the new parcels.&lt;/P&gt;&lt;P&gt;The locators were created in ArcMap. Below is the entire script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
from arcgis.gis import GIS

arcpy.env.overwriteOutput = True

# Variables
server = 'https://arcgisserver.com/portalt'
user = 'user'
password = 'Passwrod'
ArcGISFS = '\\\\locators\\TESTLocator'

# Connect to portal
gis = GIS(server, user, password, verify_cert=False)
print('     Connected to portal test')

# Stop services that are "GeocodeServer" type and "parcel" in name
for server in gis_server: 
    if (server.url == 'https://arcgisserver/admin'):
        for service in server.services.list():
            if service.properties.type == 'GeocodeServer' and "parcel" in service.properties.serviceName:
                        service.stop()
                        print(service.properties["serviceName"]  + ' stopped')

# Rebuild locators in ArcGISFS\arcgissource\locators folder
for locator in os.listdir(ArcGISFS):
         if locator.lower().endswith (".loc"):
            print (locator)
			locbaseGISFS= str(os.path.splitext(os.path.basename(locator))[0])
             locnameGISFS= ArcGISFS+"\\"+locbaseGISFS

            # Select parcel related locators and NOT Composite locators
            if ("composite") not in locbaseGISFS.lower() and ("parcel") in locbaseGISFS.lower() or ("parcen") in locbaseGISFS.lower():
			print('Rebuilding locators in arcgissource\locators folder')


                 try:
                     # Rebuild locators
                    print('     Rebuilding ' + locnameGISFS)
                     arcpy.RebuildAddressLocator_geocoding(locnameGISFS)
                     print(arcpy.GetMessages())

                 except:
                     messageGISFS = arcpy.GetMessages()
					 
# Start services that are "GeocodeServer" type and "parcel" in name
for server in gis_server:
    if (server.url == 'https://arcgisserver/admin'):
        for service in server.services.list():
            if service.properties.type == 'GeocodeServer' and "parcel" in service.properties.serviceName:
                        service.start()
                        print(service.properties["serviceName"]  + ' started')&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;</description>
      <pubDate>Thu, 29 Jul 2021 17:50:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stop-start-locator-service-with-specific-word-in/m-p/1084105#M61889</guid>
      <dc:creator>AliciaShyu</dc:creator>
      <dc:date>2021-07-29T17:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Stop start locator service with specific word in name</title>
      <link>https://community.esri.com/t5/python-questions/stop-start-locator-service-with-specific-word-in/m-p/1084231#M61893</link>
      <description>&lt;P&gt;You should not use 'server' as a variable for your server URL as well as a variable to loop thru servers in your enterprise environment.&lt;/P&gt;&lt;P&gt;Add the line gis_servers = gis.admin.servers.list() and loop thru this list with a different variable than 'server'.&lt;/P&gt;&lt;P&gt;Your code will only locate geocode services in the root server folder.&amp;nbsp; If you have geocode services in subfolders you will need to explicitly state those folder names&lt;/P&gt;&lt;P&gt;eg. for service in server.services.list(folder='Your folder name'):&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jul 2021 21:35:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stop-start-locator-service-with-specific-word-in/m-p/1084231#M61893</guid>
      <dc:creator>MikeVolz</dc:creator>
      <dc:date>2021-07-29T21:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: Stop start locator service with specific word in name</title>
      <link>https://community.esri.com/t5/python-questions/stop-start-locator-service-with-specific-word-in/m-p/1084244#M61894</link>
      <description>&lt;P&gt;You may need to check against a lowercase service name, as the `in` operator is case sensitive. Additionally, what MikeVolz suggested re root folder is also worth looking at.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;"parcel" in service.properties.serviceName.lower()&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 29 Jul 2021 22:11:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stop-start-locator-service-with-specific-word-in/m-p/1084244#M61894</guid>
      <dc:creator>nzjs</dc:creator>
      <dc:date>2021-07-29T22:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: Stop start locator service with specific word in name</title>
      <link>https://community.esri.com/t5/python-questions/stop-start-locator-service-with-specific-word-in/m-p/1084376#M61899</link>
      <description>&lt;P&gt;Thanks, I'll change the variable.&lt;/P&gt;&lt;P&gt;The code is correct, all our public geocode services are in the root server folder.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 12:35:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stop-start-locator-service-with-specific-word-in/m-p/1084376#M61899</guid>
      <dc:creator>AliciaShyu</dc:creator>
      <dc:date>2021-07-30T12:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Stop start locator service with specific word in name</title>
      <link>https://community.esri.com/t5/python-questions/stop-start-locator-service-with-specific-word-in/m-p/1084403#M61902</link>
      <description>&lt;P&gt;Thank you so much, this fixed my script.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Jul 2021 14:05:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/stop-start-locator-service-with-specific-word-in/m-p/1084403#M61902</guid>
      <dc:creator>AliciaShyu</dc:creator>
      <dc:date>2021-07-30T14:05:14Z</dc:date>
    </item>
  </channel>
</rss>

