|
POST
|
I am working on a standalone script that is supposed to stop a few geocoding services, then rebuild the address locators used in those services, then start the geocoding services. It is supposed to run on a standalone, non-federated ArcGIS Server (version 10.9.1) (the same server that the services were published to) in a DMZ server network. The script is running on the server itself because machines on my internal network cannot connect with the DMZ server in the ways that are needed for this script. I am using the ArcGIS API for Python to stop and start the services, and I based those parts of the script on sample code from Esri. The geocoding services were published on the ArcMap runtime, and today I created a Pro runtime geocoding service, and the script didn't stop that service either. I am running the script in Command Prompt and sometimes in IDLE. PROBLEM: The script does not stop the geocoding services, yet it moves through that part of the script without throwing an error. I can see in Server Manager online that the services are never stopped. It only hits an error when it tries to rebuild an address locator but can't do it because the geocoding service was not actually stopped first. I have run out of ideas of how to troubleshoot or fix this. I have double-checked everything I can think of to check - credentials, names and paths, etc. The credentials being used can indeed stop the services manually in Server Manager. Does anyone have any ideas? Here is the core of the code: import sys
import datetime
from arcgis.gis.server import Server # ArcGIS API for Python
import arcpy
import keyring
if __name__ == "__main__":
# Folder path where the locator is, not the service:
arcpy.env.workspace = r'D:\RootFolder\OtherFolder'
# Name of folder in the Server Manager where the locator lives:
folder_folder_name = 'MyFolder' # File Explorer folder name
ags_folder_name = 'MY_FOLDER' # ArcGIS Server Manager folder name
# Base URL of the ArcGIS Server where the service lives:
server_base_url = r'https://myserverbaseurl:port'
# Names of the locators (not services):
locator_name_list = ['LOCATOR_ROAD', 'LOCATOR_POINTS', 'LOCATOR_ADDR']
# Names of the geocoding services published to the server:
locservice1 = 'MY_FAV_SERVICE'
locservice2 = 'THE_OTHER_SERVICE'
username = keyring.get_password('name', 'user')
pw = keyring.get_password('other_name', 'password')
# Create an instance of a Server object in ArcGIS API for Python.
server = Server(url='{}/arcgis/admin'.format(server_base_url), username=username, password=pw)
# Access server content (ArcGIS API for Python)
cdir = server.content
# Instantiate the services as service objects
service1 = cdir.get(locservice1, folder=ags_folder_name)
service2 = cdir.get(locservice2, folder=ags_folder_name)
# TEST - this worked.
#print(service1.service.iteminformation)
#print(cdir) # This worked.
# Stop the geocoding services in order to next rebuild the locators
service1.service.stop()
service2.service.stop()
# Rebuild the locators.
for locator_name in locator_name_list:
print(locator_name)
arcpy.geocoding.RebuildAddressLocator(locator_name)
# Start the services after rebuilding. (ArcGIS API for Python)
service1.service.start()
service2.service.start()
... View more
01-25-2023
06:10 PM
|
1
|
3
|
2760
|
|
POST
|
Thank you so much! Whoops, it had not occurred to me to do something like that. It worked!
... View more
01-25-2023
12:37 PM
|
0
|
0
|
4009
|
|
POST
|
Please help... I have done so many google searches for this and... nothing. Whyyyy? What is the file/directory location or path of the ArcGIS API for Python, particularly on an ArcGIS Server? I am having extremely mysterious failure with a standalone script that is trying to use the API to stop services, so I want to find some way to check if the API really exists on this server where I'm running the script. Thank you!
... View more
01-25-2023
11:24 AM
|
0
|
4
|
4049
|
|
POST
|
I think I figured it out. I haven't 100% tested this yet, but I believe the error resulted from the .aprx being Pro 3.0 while the machine I was running my script on had Pro 2.7, so it could not open or use the .aprx. I am going to upgrade that machine to Pro 3.0 sometime this week. Update: it worked!
... View more
01-23-2023
04:17 PM
|
2
|
2
|
9768
|
|
POST
|
I'm having the same error, but with my .aprx path, not with a toolbox path. Have any of you been able to solve the problem? Thanks!
... View more
01-23-2023
11:16 AM
|
0
|
3
|
9770
|
|
POST
|
Hi Adrian, Thanks for your reply! It turns out that my survey's problem was actually due to a server being attacked by bots and timing out. Good luck! Allen
... View more
01-03-2022
02:15 PM
|
0
|
0
|
8148
|
|
POST
|
Hi @AdrianDoss , Did you ever resolve this error? I am currently facing the same problem. Thanks! Allen
... View more
12-28-2021
05:26 PM
|
0
|
2
|
8179
|
|
BLOG
|
@IanGallo No, unfortunately I didn't pursue it a lot farther and didn't find a way to do it. Yes, I think we are talking about the same thing. If you find a way to do it, let me know! 🙂
... View more
11-16-2021
02:23 PM
|
1
|
0
|
11841
|
|
POST
|
To answer your question, I use a concurrent use license, Standard license, with no special extensions unless I need them for a specific task. My problem (described in the original post) was because I had not connected to my organization's licensing in ArcGIS Pro. Whoops. So I was attempting to use Pro without any license.
... View more
09-28-2021
02:10 PM
|
0
|
0
|
10468
|
|
POST
|
Thank you, Jonathan! I appreciate your reply. I don't really know anything about requests and scripting internet-related things (someone else wrote the scripts that I have to work with), so I don't yet understand what those sources are talking about, but I will keep doing research and learning. You have given me a helpful starting place, with those links and your reply. Thank you!!
... View more
09-23-2021
01:23 PM
|
0
|
0
|
1635
|
|
POST
|
Hello, I have done lots of searching about this but have not found anything in Esri documentation or here in the Community, so I thought I'd see if anyone can help. My organization is in the midst of a server migration. In our old ArcGIS Server environment, we had token authentication, but in the new one, we have web-tier authentication. I am trying to migrate a Python script that rebuilt an address locator in the old environment; the script includes stopping and then starting services, which is necessary for rebuilding the address locator. I have 2 main problems: The first problem is that I have no idea how to write Python for web-tier authentication, instead of tokens. I have researched this but haven't found anything. Any suggestions? The second problem is that it sounds like it's not possible to stop/start services via a script anymore, at least not as simply as in the past (see: https://community.esri.com/t5/arcgis-enterprise-questions/start-stop-secure-services-in-10-6-1/td-p/646090 ). I saw that it is possible to do it with the ArcGIS API for Python, but that it requires that the server be federated (https://support.esri.com/en/technical-article/000019994 ). The involved servers are not federated, unfortunately, but we have other servers that are federated. Does anyone know how to stop/start services in a script, services that are not on a federated server? Thanks so much! Allen
... View more
09-14-2021
12:16 PM
|
1
|
2
|
1728
|
|
POST
|
Thank you very much, JeffK and JoshuaBixby, for your helpful replies!!
... View more
02-02-2021
04:16 PM
|
0
|
0
|
3912
|
|
POST
|
Hi! I am hoping to achieve this exact thing. Did you ever figure out how to do it, @ClintonCooper1 ? Thanks!
... View more
02-02-2021
10:35 AM
|
0
|
0
|
3926
|
|
POST
|
Well, I finally fixed it. I think it came down to correcting my Pro license. I feel kind of dumb for not doing that to begin with, but it is also frustrating that there was no hint anywhere along the line that it was an issue. I installed ArcMap on the server to see if the ArcMap version of arcpy would work any better than the Pro version. When I did the installation, ArcMap forced me to look at the license manager and deal with it, and I realized that I didn't recall doing anything with that when I installed Pro, even though I did log into Pro with my AGOL account just fine. I went into the licensing settings in Pro, saw that they were incorrect, and I corrected them. Then I went back to PyCharm. I went to edit the settings for the project interpreter. This time, it had "system environment" as an option, along with conda or virtual environment. This seemed like a good sign, because I had seen instructions to use "system environment" in online resources, but it was never available as an option to me. So I picked "system environment" and the same Python path I had tried before, C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe I chose to "inherit global site packages," as I already had done in my previous attempts. And, this time it worked! My script successfully imported arcpy and ran! So it was all just a licensing issue. Ugh. I really wish there had been an error message somewhere along the way, either when I attempted to import arcpy, or when I opened/used Pro itself, that my license wasn't valid.
... View more
01-14-2021
11:15 AM
|
2
|
2
|
12119
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-30-2025 05:49 PM | |
| 1 | 09-30-2025 03:01 PM | |
| 1 | 09-30-2025 05:42 PM | |
| 1 | 11-01-2023 11:39 AM | |
| 1 | 11-21-2024 04:21 PM |
| Online Status |
Offline
|
| Date Last Visited |
3 weeks ago
|