Select to view content in your preferred language

UploadServiceDefinition has gotten finicky - bug or feature?

2535
0
03-10-2014 10:44 AM
PaulSimpson
Occasional Contributor
We have been using a python script using desktop ArcGIS 10.1 to generate ArcGIS Online maps all winter.  Here is the web app showing the maps we have been generating: sniffer maps.

Last week one of our techs reported the script was succeeding (no errors thrown) but nothing was showing up in his ArcGIS Online contents.  I tried when I got back today and got the following error:

ERROR: code:500, Invalid name 'Sniffer Run 2014-03-03, Fairbanks, AK' found in input publish parameters, Cannot connect to this server.
Failed to execute (UploadServiceDefinition).


The name, 'Sniffer Run 2014-03-03, Fairbanks, AK' is the service_name passed to arcpy.mapping.CreateMapSDDraft, and is computer generated.

I had to eliminate spaces, commas and dashes to make it work.  There appears to have been a change in the ESRI side which makes our service_name convention no longer valid during the UploadServiceDefinition stage.  Is this a feature or a bug?  (Maybe a programmer specified the wrong string encoding.) 

This makes the map names much less readable for our Online map users, so if we can go back to the way it was we would appreciate it muchly.

Thanks!

Paul

Here is a snippet showing the service definition portion of the code:

        service = "Sniffer Run " + numdate + ", " + city
        serverType = 'MY_HOSTED_SERVICES'
        onlineDirectory = "Sniffer_Maps"        # this doesn't work
            
        tellMe("Running CreateMapSDDraft ...")
        arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, service, serverType, summary=sddraftSummary, tags=sddraftTags)
        
        con = 'My Hosted Services'

        sd = os.path.join(srvdefworkspace,service + '.sd')

        # Read the sddraft xml.
        doc = DOM.parse(sddraft)
        # Change service from map service to feature service
        typeNames = doc.getElementsByTagName('TypeName')
        for typeName in typeNames:
            # Get the TypeName we want to disable.
            if typeName.firstChild.data == "MapServer":
                    typeName.firstChild.data = "FeatureServer"

        #caching
        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"

        #add disclaimer text
        disclaimer = 'a text string'
        disclaimNode = doc.createTextNode(disclaimer)
        acc = doc.getElementsByTagName("AccessInformation")[0]
        acc.appendChild(disclaimNode)

        # add org credits
        credits = "FNSB Air Quality"
        cre = doc.getElementsByTagName("Credits")[0]
        if cre.childNodes == []:
            credNode = doc.createTextNode(credits)
            cre.appendChild(credNode)

        tellMe("Writing XML ...")
        outXml = os.path.join(srvdefworkspace,'HostedMSNew.sddraft') 
        f = open(outXml, 'w')     
        doc.writexml( f )     
        f.close()
        tellMe("Running AnalyzeForSD ...")
        analysis = arcpy.mapping.AnalyzeForSD(outXml)
        if len(analysis['errors'])>0:
            tellMe( str(analysis))
            sys.exit(analysis['errors'])
        
        #arcpy.SignOutFromPortal_server()
##        tellMe("Signing In ...")
##        username = "*****"
##        password = "*****"
##        arcpy.SignInToPortal_server(username,password,"http://www.arcgis.com/")
        tellMe("Running StageService_server ...")
        arcpy.StageService_server(outXml, sd)
        tellMe("Running UploadServiceDefinition_server ...")
        sharegroup = "Sniffer Map Feature Layer Services"
        override = "OVERRIDE_DEFINITION"
        arcpy.UploadServiceDefinition_server(sd, con, in_override=override, in_public = "PUBLIC", in_groups=sharegroup)
Tags (2)
0 Kudos
0 Replies