AnsweredAssumed Answered

Setting the Time Zone when publishing Map Service via ArcPy?

Question asked by kreuzrsk on Aug 2, 2019
Latest reply on Aug 27, 2019 by JA_Eckman

We are using a bare bones ArcPy Script from the ESRI site to publish Map Services from ArcGIS Pro projects.  When publishing, the default Time Zone is none but we want it changed to Pacific Time with values adjusted for daylight savings.  Is there a way to do this when using arcpy when publishing?

 

for m in aprx.listMaps():
    if mapNames == "ALL" or mapNames == m.name:
        AddMsgAndPrint("Map: " + m.name)
        serviceName = m.name   
        SDPath = os.path.join(tempPath, serviceName + ".sd")
   
        # Create MapServiceDraft and set service properties
        sddraft = arcpy.sharing.CreateSharingDraft('STANDALONE_SERVER', 'MAP_SERVICE', serviceName, m)
        sddraft.targetServer = server_con
        sddraft.serverFolder = serverFolder
        # copyDataToServer = False will reference data from registered data sources with the targetServer
        sddraft.copyDataToServer = False
        sddraft.exportToSDDraft(SDdraftPath)
       
        # Read the contents of the original SDDraft into an xml parser
        doc = DOM.parse(SDdraftPath)
       
        # The follow code piece modifies the SDDraft from a new MapService with caching capabilities
        # to a FeatureService with Map, Create and Query capabilities.
        typeNames = doc.getElementsByTagName('TypeName')
        for typeName in typeNames:
            if typeName.firstChild.data == "FeatureServer":
                extention = typeName.parentNode
                for extElement in extention.childNodes:
                    if extElement.tagName == 'Enabled':
                        extElement.firstChild.data = 'false'
       
        # Turn off 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"
       
        # Write the new draft to disk
        f = open(newSDdraftPath, 'w')
        doc.writexml(f)
        f.close()
       
        # Stage the service
        arcpy.StageService_server(newSDdraftPath, SDPath)
        AddMsgAndPrint("  Staged service")
       
        # Upload the service
        arcpy.UploadServiceDefinition_server(SDPath, server_con)
        AddMsgAndPrint("  Uploaded service")
       
        # Delete drafts
        Cleanup(SDdraftPath)
        Cleanup(newSDdraftPath)
        Cleanup(SDPath)
        AddMsgAndPrint("  Removed temp files")

Outcomes