-1

I currently have to have ArcMap open and the connection to my ArcGIS server established in catalog to run my script which publishes MXD files.

con = r'C:\...\myserver.ags'
arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, service, 'ARCGIS_SERVER', con, True, serverFolder)
analysis = arcpy.mapping.AnalyzeForSD(sddraft)
arcpy.StageService_server(sddraft, sd)
arcpy.UploadServiceDefinition_server(sd, con)

I was wondering if there was a way to cut out the part of having to have ArcMap open and manually turning on the server connection. Perhaps connecting some socket or something?

0

The first parameter of CreateMapSDDocument, map_document, is:

A variable that references a MapDocument object. The data frame that was active at the time the map_document was saved will be published.

Consequently, I would expect this would work:

mapDoc = arcpy.mapping.MapDocument(PATH TO YOUR MXD)
arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, service, 'ARCGIS_SERVER', con, True, serverFolder

If not perhaps you can expand your snippet to include that and tell us what happens when that is run.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.