2

I am trying to execute the pythonscript code for the automation of a mapservice. While execution tempdraft.sddraft, and updatedDraft.sddraft files are automatically generated but .SD file has not generated. And I am getting the error :

Runtime error Traceback (most recent call last): File "", line 1, in File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\server.py", line 1293, in UploadServiceDefinition raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Service Definition: Dataset C:\msurya\teritory.sd does not exist or is not supported Failed to execute (UploadServiceDefinition).

Can somebody help how to solve this problem for automation of publishing a service?

import arcpy, os, sys
... import xml.dom.minidom as DOM
...  
... arcpy.env.overwriteOutput = True
... serviceName = "teritory"
... tempPath = r"C:\msurya"
... 
>>> path2MXD = r"C:\msurya\teritory.mxd"
... userName = " "
... passWord = " "
... 
>>> SDdraft = os.path.join(tempPath, "tempdraft.sddraft")
... newSDdraft = os.path.join(tempPath, "updatedDraft.sddraft")
... SD = os.path.join(tempPath, serviceName + ".sd")
... 
>>> arcpy.SignInToPortal_server(userName, passWord, "https://sce2.maps.arcgis.com/")
<Result 'true'>
>>> mxd = arcpy.mapping.MapDocument(path2MXD)
... arcpy.mapping.CreateMapSDDraft(mxd, SDdraft, serviceName, "MY_HOSTED_SERVICES")
... 
>>> doc = DOM.parse(SDdraft)
>>> tagsType = doc.getElementsByTagName('Type')
... for tagType in tagsType:
...     if tagType.parentNode.tagName == 'SVCManifest':
...         if tagType.hasChildNodes():
...             tagType.firstChild.data = "esriServiceDefinitionType_Replacement"
...             tagsState = doc.getElementsByTagName('State')
... for tagState in tagsState:
...     if tagState.parentNode.tagName == 'SVCManifest':
...         if tagState.hasChildNodes():
...             tagState.firstChild.data = "esriSDState_Published"
...  
... # Change service type from map service to feature service
... typeNames = doc.getElementsByTagName('TypeName')
... for typeName in typeNames:
...     if typeName.firstChild.data == "MapServer":
...         typeName.firstChild.data = "FeatureServer"
...         configProps = doc.getElementsByTagName('ConfigurationProperties')[0]
... propArray = configProps.firstChild
... propSets = propArray.childNodes
... for propSet in propSets:
...     keyValues = propSet.childNodes
...     for keyValue in keyValues:
...         if keyValue.tagName == 'Key':
...             if keyValue.firstChild.data == "isCached":
...                 keyValue.nextSibling.firstChild.data = "false"
...                 configProps = doc.getElementsByTagName('Info')[0]
... propArray = configProps.firstChild
... propSets = propArray.childNodes
... for propSet in propSets:
...     keyValues = propSet.childNodes
...     for keyValue in keyValues:
...         if keyValue.tagName == 'Key':
...             if keyValue.firstChild.data == "WebCapabilities":
...                 keyValue.nextSibling.firstChild.data = "Query,Create,Update,Delete,Uploads,Editing"
...                 
>>> f = open(newSDdraft, 'w')
... doc.writexml( f )
... f.close()
... analysis = arcpy.mapping.AnalyzeForSD(newSDdraft)
... 
>>> if analysis['errors'] == {}:
...     # Stage the service
...     arcpy.StageService_server(newSDdraft, SD)
...     
>>> arcpy.UploadServiceDefinition_server(SD,"My Hosted Services",serviceName,"","","","","OVERRIDE_DEFINITION","SHARE_ONLINE","PUBLIC","SHARE_ORGANIZATION","")

Runtime error Traceback (most recent call last): File "", line 1, in File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\server.py", line 1293, in UploadServiceDefinition raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Service Definition: Dataset C:\msurya\teritory.sd does not exist or is not supported Failed to execute (UploadServiceDefinition).

closed as off-topic by PolyGeo Sep 24 '16 at 22:30

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.