Value error - CreateMapSDDraft

11-08-2016 06:58 AM
New Contributor

I'm trying to overwrite an existing map service in ArcGIS server 10.4.1 using ArcPy. It doesn't appear to be able to see my server and gives a value error (ValueError: GIS Servers/arcgis on MYSERVER.nuim.ie_6080 (admin)) when I run using cmd prompt.

It is failing at line 31 saying suggesting that the 'con =' parameter is invalid. I have checked this however and the input I have corresponds with my server name in ArcGIS catalogue.  

Any advice would be greatly appreciated.

0 Kudos
3 Replies
Esri Frequent Contributor

From your screenshot, it doesn't appear like you're running this from the python window in ArcMap. ArcMap knows how to contruct the full path of the connection files within the GIS Servers folder in the Catalog window.  I suggest you copy the connection from the GIS Servers folder to somewhere on your file system, and provide the absolute path to it so the script knows where to find it.  You can also point the script to the actual path that the connection file exists in when using GIS Servers, which is C:\Users\<user>\AppData\Roaming\ESRI\Desktop<version>\ArcCatalog\<connection file name>.  As you can see, it may be easier to move the file to a more friendly path.

0 Kudos
New Contributor

Many thanks for the advice. We were testing the script in the CMD window as we hope to have it run as a Windows scheduled task. I tried it in the Python window in ArcMap and it found the server and didn't give me this error anymore. 

I will try the absolute path suggestion which might hopefully let us run this script as a scheduled task in a batch file.


0 Kudos
MVP Honored Contributor

I don't know much (anything) about connection files, but the help (and example within) indicates that the connection string should end in '.ags'. Can you try:

con = 'GIS Servers/arcgis on MYSERVER.nuim.ie_6080 (admin).ags'‍‍‍