Value Error on connecrtion file to arcgis server

337
2
Jump to solution
04-06-2017 12:10 PM
ChuckBenton
Occasional Contributor

I'm trying to share/publish an mxd using a python script, and starting by using CreateMapSDDraft.

When I run the script I get "Value Error" followed by the path to the ArcGIS server:  'C:\Users\paa-admin\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\arcgis on paa-server_6080 (admin).ags'

When I run my script (using PyScripter) with ArcMap opened using NPLC.mxd, I get an error stating "Cannot get exclusive schema lock. Either being edited or in use by another application". This indicates to me that the path is valid.

I've looked at http://desktop.arcgis.com/en/arcmap/10.4/analyze/arcpy-mapping/createmapsddraft.htm

I've also looked at https://community.esri.com/thread/185559-value-error-createmapsddraft, which helped me identify that I should be using the full path.

The following is a code snippet, the key line being

con = 'C:\Users\paa-admin\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\arcgis on paa-server_6080 (admin).ags'

with the error coming from

analysis = arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, service, 'ARCGIS_SERVER',
                                          con, True, None, summary, tags)

Any suggestions are most appreciated! I'm a Python newbie so I apologize in advance if this is an obvious error on my part!!

#Now share NPLC as a service
# define local variables
wrkspc = r"C:\\Users\\paa-admin\\Documents\\MapsandGeodatabase\\"
mapDoc = arcpy.mapping.MapDocument(wrkspc + 'NPLC.mxd')
con = 'C:\Users\paa-admin\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\arcgis on paa-server_6080 (admin).ags'
service = 'NPLC'
sddraft = wrkspc + service + '.sddraft'
sd = wrkspc + service + '.sd'
summary = 'PNational Parcel Layer Content'
tags = 'parcel'

# create service definition draft
analysis = arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, service, 'ARCGIS_SERVER',
                                          con, True, None, summary, tags)

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Esteemed Contributor

well this is what I got with your con path... albeit I was using python 3, but it appears that raw formatting might help

if not, it is a good habit to get into.  See if this improves things...

con = 'C:\Users\paa-admin\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\arcgis on paa-server_6080 (admin).ags'
  File "<ipython-input-49-49f1dbc4e1cb>", line 1
    con = 'C:\Users\paa-admin\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\arcgis on paa-server_6080 (admin).ags'
         ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

# a little 'r' goes a long way sometimes

con = r'C:\Users\paa-admin\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\arcgis on paa-server_6080 (admin).ags'

View solution in original post

0 Kudos
2 Replies
DanPatterson_Retired
MVP Esteemed Contributor

well this is what I got with your con path... albeit I was using python 3, but it appears that raw formatting might help

if not, it is a good habit to get into.  See if this improves things...

con = 'C:\Users\paa-admin\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\arcgis on paa-server_6080 (admin).ags'
  File "<ipython-input-49-49f1dbc4e1cb>", line 1
    con = 'C:\Users\paa-admin\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\arcgis on paa-server_6080 (admin).ags'
         ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

# a little 'r' goes a long way sometimes

con = r'C:\Users\paa-admin\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\arcgis on paa-server_6080 (admin).ags'

View solution in original post

0 Kudos
ChuckBenton
Occasional Contributor

That was it!!!  Further proof of my newbie status... I know all about the 'r' but for some reason overlooked it.

Thanks!!!! 

Chuck

0 Kudos