Hello everyone,
I am hoping to gain a better understanding of how arcpy.Exists() interprets an ArcGIS Server (.ags) connection file (currently using ArcGIS Pro 2.8.1)
After some testing, including the .ags file extension within the string variable will return False while excluding it will return True.
Examples:
import arcpy
test01 = arcpy.Exists("C:\\Path\\To\\Connection\\sample_ags_file.ags")
print(test01)
False
test02 = arcpy.Exists("C:\\Path\\To\\Connection\\sample_ags_file")
print(test02)
True
Could someone enlighten me as to why the .ags extension returns False? Or is it bad practice to use arcpy.Exists() when attempting to verify the existence of .ags files? I appreciate any clarification!
does arcpy.Describe 's dataType return. Exists will work for workspaces or files.
I don't have anything to check with
Good suggestion.
For "C:\\Path\\To\\Connection\\sample_ags_file", the dataType is shown as ServerConnection.
For "C:\\Path\\To\\Connection\\sample_ags_file.ags", the script errors out and says the file does not exist.
I'm assuming .ags extensions need to be excluded when using them with arcpy, but I'm unsure why that is the case if true.
or maybe something like
import os.path
os.path.exists(file_path)
Yep I can confirm it exists with that (and will likely go that route), but I'm more curious about how .ags file extensions and arcpy.Exists() interact, since I'm seeing different results with/without the extension.