Created
October 23, 2014 17:56
-
-
Save amarinelli/938d90003c6501ac440d to your computer and use it in GitHub Desktop.
Workaround to validate an AGS connection file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
import os | |
outdir = r'C:\TEMP' | |
out_folder_path = outdir | |
out_name = 'test_connection.ags' | |
server_url = 'http://localhost:6080/arcgis/admin' | |
username = 'admin' | |
password = 'admin' | |
agsFile = os.path.join(outdir, out_name) | |
if os.path.exists(agsFile): | |
os.remove(agsFile) | |
arcpy.mapping.CreateGISServerConnectionFile("ADMINISTER_GIS_SERVICES", | |
out_folder_path, | |
out_name, | |
server_url, | |
"ARCGIS_SERVER", | |
True, | |
"#", | |
username, | |
password, | |
"SAVE_USERNAME") | |
try: | |
folders = arcpy.ListDataStoreItems(agsFile, "FOLDER") | |
print folders | |
except: | |
# Handle bad connection file | |
print "The connection failed" | |
print "\ndone" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment