python - manage workspace for dynamic layers

3471
0
10-13-2014 06:36 AM
giancarlorazzino
New Contributor

Hi,

using python, I would like to manage the publication of a map service with the property of the capabilities Mapping "manage workspace for dynamic layers"

using the following piece of code (highlighted part)

import arcpy

import os.path

import xml.dom.minidom as DOM

………

arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, service, 'ARCGIS_SERVER', con, True, "FS", summary, tags)

doc = DOM.parse(sddraft)

keys = doc.getElementsByTagName('Key')

for key in keys:

        if key.firstChild.data == 'enableDynamicLayers': key.nextSibling.firstChild.data = True

        if key.firstChild.data == 'dynamicDataWorkspaces': key.nextSibling.firstChild.data =[{"id":"MyFile_GDBWorkspaceID","workspaceFactory":"FileGDB","workspaceConnection":"database=C:\\PIR\fase230\\PIR_Giugno2014.gdb"}]

        if key.firstChild.data == 'maxRecordCount': key.nextSibling.firstChild.data = 5000

services___ = doc.getElementsByTagName('TypeName')

for service__ in services___:

        if service__.firstChild.data == 'KmlServer':

service__.parentNode.getElementsByTagName('Enabled')[0].firstChild.data = 'false'

        if service__.firstChild.data == 'WMSServer':

service__.parentNode.getElementsByTagName('Enabled')[0].firstChild.data = 'true'

# save changes

if os.path.exists(sddraft): os.remove(sddraft)

f = open(sddraft,"w")

doc.writexml(f)

f.close()

        arcpy.StageService_server(sddraft, sd)

arcpy.UploadServiceDefinition_server(sd, con, service, inCluster)

I have the following error:

exceptions.AttributeError: 'NoneType' object has no attribute 'data'               

I think there is an error in the values ​​that pass

Thank you for your help

0 Kudos
0 Replies