CÓMO
Al publicar una capa de entidades desde ArcGIS Pro, es posible establecer una zona horaria y especificar el horario de verano con ArcPy modificando las propiedades de configuración para la publicación.
import arcpy import os import xml.dom.minidom as DOM import codecs import xml.etree.ElementTree as ET
def enable_extensions(sddraftPath, soe): doc = DOM.parse(sddraftPath) typeNames = doc.getElementsByTagName('TypeName') for typeName in typeNames: if typeName.firstChild.data == soe: extension = typeName.parentNode for extElement in extension.childNodes: if extElement.tagName == 'Enabled': extElement.firstChild.data = 'true' f = open(sddraftPath, 'w') doc.writexml(f) f.close()
def enable_configproperties(sddraftPath, soe, property_set): doc = DOM.parse(sddraftPath) typeNames = doc.getElementsByTagName('TypeName') for typeName in typeNames: if typeName.firstChild.data == soe: extension = typeName.parentNode # prp = extension.childNodes.getElementsByTagNameNS('PropertyArray') for extElement in extension.childNodes: if extElement.tagName == 'Definition': for definition in extElement.childNodes: if definition.tagName == 'ConfigurationProperties': for config_prop in definition.childNodes: if config_prop.tagName == 'PropertyArray': for prop in property_set: prop_set = doc.createElement("PropertySetProperty") attr = doc.createAttribute("xsi:type") attr.value = "typens:PropertySetProperty" prop_set.setAttributeNode(attr) prop_key = doc.createElement("Key") txt = doc.createTextNode(prop["key"]) prop_key.appendChild(txt) prop_set.appendChild(prop_key) prop_value = doc.createElement("Value") attr = doc.createAttribute("xsi:type") attr.value = "xs:string" prop_value.setAttributeNode(attr) txt = doc.createTextNode(prop["value"]) prop_value.appendChild(txt) prop_set.appendChild(prop_value) config_prop.appendChild(prop_set) f = open(sddraftPath, 'w') doc.writexml(f) f.close()
Nota: Puede haber un error al conectarse al portal a través de arcpy.SignInToPortal(). Consulte Problema: No se puede iniciar sesión en ArcGIS Online con ArcPy para obtener más información.
if __name__ == "__main__": arcpy.SignInToPortal("https://www.arcgis.com/", "username", "password") # aprx = arcpy.mp.ArcGISProject("CURRENT") aprx = arcpy.mp.ArcGISProject(r"aprx path") m = aprx.listMaps('<Map_Name>')[0] # si se utiliza para compartir capas seleccionadas # layers = m.listLayers() # lyr = layers[0] name = "service name" in_server = "https://server.domain.com:6443/arcgis/" sddraft = m.getWebLayerSharingDraft('FEDERATED_SERVER', 'MAP_IMAGE', name) sddraft.federatedServerUrl = in_server sddraft.copyDataToServer = False sddraft.exportToSDDraft("location and name of sddraft") #The desired timezone can be in UTC or PDT property_set = [{ "key": "dateFieldsRespectsDayLightSavingTime", "value": "true" }, { "key": "dateFieldsTimezoneID", "value": "<desired_timezone>" }] # Para establecer la zona horaria del servicio de entidades alojado, soe = "FeatureServer" enable_configproperties(sddraftPath, soe="MapServer", property_set=property_set) # Se habilitan extensiones en el servidor de mapas enable_extensions(sddraftPath, "FeatureServer") # enable_extensions(sddraftPath, "VersionManagementServer") # enable_extensions(sddraftPath, "LRServer") print("Start Staging") arcpy.StageService_server("location and name of sddraft", "location and name of sd") print("Start Uploadinb") arcpy.UploadServiceDefinition_server("location and name of sd", in_server) print("Finish publishing")
Id. de artículo: 000024162
Obtener ayuda de expertos en ArcGIS
Empieza a chatear ahora