I have a REST maintenance script that I inherited that was written for ArcGIS Pro 2.6. It checks to see if the AGS connection is valid.
### ArcServer Connection ###
arcserver_ags_file = r"D:\_AGS_Connection\giswebsite@ArcServer@GIS_Admin.ags"
#### ArcServer Check ###
if arcpy.Exists(arcserver_ags_file) == True:
print("The following arcserver_ags_file will be used: " + str(arcserver_ags_file))
if arcpy.Exists(arcserver_ags_file) == False:
print("Stopping the script because your arcserver_ags_file is not set or does not exist.")
exit()
Since the upgrade from Pro 2.6 to 2.8.2, the script ends because it doesn't recognize the AGS file. The user has full access to the file location and verified that the AGS connection is accessible and able to connect to it.
I'm a beginner at python that can interpret/understand code but by no means considered a developer. Any assistance in getting this solved is much appreciated.
Solved! Go to Solution.
@Min-DongChang I was able to reproduce this, so I believe this is a bug. To workaround this issue, you could use os.path.isfile in place of arcpy.Exists. Ex:
import arcpy, os
arcserver_ags_file = r"D:\_AGS_Connection\giswebsite@ArcServer@GIS_Admin.ags"
#### ArcServer Check ###
if os.path.isfile(arcserver_ags_file) == True:
print("The following arcserver_ags_file will be used: " + str(arcserver_ags_file))
if os.path.isfile(arcserver_ags_file) == False:
print("Stopping the script because your arcserver_ags_file is not set or does not exist.")
@Min-DongChang I was able to reproduce this, so I believe this is a bug. To workaround this issue, you could use os.path.isfile in place of arcpy.Exists. Ex:
import arcpy, os
arcserver_ags_file = r"D:\_AGS_Connection\giswebsite@ArcServer@GIS_Admin.ags"
#### ArcServer Check ###
if os.path.isfile(arcserver_ags_file) == True:
print("The following arcserver_ags_file will be used: " + str(arcserver_ags_file))
if os.path.isfile(arcserver_ags_file) == False:
print("Stopping the script because your arcserver_ags_file is not set or does not exist.")
Thank you Jake! Worked like a charm.