Skip to main content

exportToSDDraft

汇总

MapServiceDraft 类允许您为 地图服务 创建服务定义草稿文件 (.sddraft),该文件将向 ArcGIS Server 复制所有数据或引用注册数据。

讨论

要创建 MapServiceDraft 对象,请使用 arcpy.sharing.CreateSharingDraft 函数并将 server_type 参数设置为 STANDALONE_SERVER 以及将 service_type 参数设置为 MAP_SERVICE 。 随后即可通过设置服务级别属性和元数据属性来配置 MapServiceDraft 对象。 可以使用 targetServer 属性以指定将地图服务发布到的服务器。

您也可以通过修改 .sddraft 文件设置地图服务属性。 如果没有为属性指定值,则会设置默认值。 即使要覆盖具有已配置属性的地图服务,也必须设置相应的属性值。

注:

如果未设置元数据属性( credits 、 description 、 summary 、 tags 和 useLimitations )或其具有空字符串,则地图服务将从地图中获取元数据。

有关创作元数据的详细信息,请参阅 编辑元数据 。

配置 MapServiceDraft 对象后,可以使用 exportToSDDraft 方法将其保存到服务定义草稿文件 (.sddraft)。 然后,可以使用 过渡服务 和 上传服务定义 工具将其过渡并共享到 ArcGIS Server。 有关详细信息,请参阅 什么是 arcpy.sharing 模块 。

将 .sddraft 文件过渡并上传到服务器后,可使用 缓存工具集 中的工具(如 管理地图服务器缓存切片 工具)创建和管理地图服务器缓存以加快地图服务显示。

代码示例可用于以下用途:

语法

exportToSDDraft()

属性

名称 说明 数据类型

cache.cacheOnDemand

(读取和写入)

指定未缓存的切片是否将按需(即当客户端应用程序请求时)创建。 默认值为 False 。

Boolean

cache.configuration

(读取和写入)

由 生成地图服务器缓存切片方案 工具生成的预定义切片方案 .xml 文件的路径和文件名。

String

cache.exportTiles

(读取和写入)

指定是否允许客户端下载地图切片以供离线使用。 默认值为 False 。

Boolean

cache.exportTilesCount

(读取和写入)

单个请求中可下载的最大切片数量。 仅在属性 cache.exportTiles 设置为 True 时支持此属性。 默认值为 100000。

Integer

cache.useExistingCache

(读取和写入)

指定是否从现有缓存中提取数据。 仅在属性 enableCache 设置为 True 时支持此属性。 默认值为 False 。

Boolean

checkUniqueIDAssignment

(读取和写入)

指定是否分析地图以确认 地图属性 中的 允许向共享 web 图层分配唯一数字 ID 选项是否已启用。 有关详细信息,请参阅 分配图层 ID 。

Boolean

copyDataToServer

(读取和写入)

指定是否将地图中的数据复制到服务器。 值为 True 时,将复制地图中的所有数据,包括在服务器中注册的数据。 值为 False 时,仅会复制未在服务器中注册的数据。 服务将引用已在服务器中注册的数据。 默认值为 False 。

Boolean

credits

(读取和写入)

地图服务的配额。

String

description

(读取和写入)

地图服务的描述。

String

enableCache

(读取和写入)

指定 Web 图层是否动态绘制或从缓存绘制。 默认值为 False 。

Boolean

enableDynamicWorkspaces

(读取和写入)

指定是否允许用户更改 Web 图层的外观或绘制行为。 默认值为 True 。

Boolean

extension.feature.allowTrueCurvesUpdates

(读取和写入)

指定是否允许 Web 客户端使用增密几何更新要素的真曲线几何。 仅当启用编辑时才支持此属性。 默认值为 True 。

Boolean

extension.feature.allowUpdateWithoutMValues

(读取和写入)

指定是否允许几何在不指定 m 值的情况下更新为启用了 m 值的要素。 默认值为 False 。

Boolean

extension.feature.featureCapabilities

(读取和写入)

已启用的功能,以逗号分隔。 支持以下功能:

  • Query

  • Create

  • Update

  • Delete

  • Sync

  • Extract

  • Editing

String

extension.feature.isEnabled

(读取和写入)

指定是否包含要素服务。 默认值为 False 。

Boolean

extension.feature.onlyAllowTrueCurveUpdatesByTrueCurveClients

(读取和写入)

指定是否只有支持真曲线的客户端(例如 ArcGIS Pro)才可以更新真曲线几何。 仅当启用编辑时才支持此属性。 默认值为 True 。

Boolean

extension.feature.zDefault.enable

(读取和写入)

指定是否允许编辑者通过不允许指定 z 值的客户端添加或更新要素。 默认值为 False 。

Boolean

extension.feature.zDefault.value

(读取和写入)

插入或更新要素时将使用的默认 z 值。 仅在属性 zDefault.enable 设置为 True 时支持此属性。 默认值为 0。

Double

extension.kml.isEnabled

(读取和写入)

指定是否启用 KML 功能。 默认值为 False 。

Boolean

extension.ogcFeature.isEnabled

(读取和写入)

指定是否启用 OGC 要素服务。 默认值为 False 。

Boolean

extension.wcs.isEnabled

(读取和写入)

指定是否启用 WCS 功能。 默认值为 False 。

Boolean

extension.wfs.isEnabled

(读取和写入)

指定是否启用 WFS 服务。 默认值为 False 。

Boolean

extension.wms.isEnabled

(读取和写入)

指定是否启用 WMS 服务。 默认值为 False 。

Boolean

mapOperations

(读取和写入)

已启用的操作,以逗号分隔。 支持以下操作:

  • Map

  • Data

  • Query

String

maxRecordCount

(读取和写入)

服务器在查询期间返回的最大记录数。 默认值为 2000。

Integer

offline

(读取和写入)

指定是否使用服务器连接。 如果设置为 False ,则必须向 targetServer 属性提供服务器 URL 或 ArcGIS Server 连接文件 (.ags),才能使用 exportToSDDraft 函数创建服务定义草稿文件 (.sddraft)。 如果设置为 True ,则可以在未填充 targetServer 属性的情况下,创建服务定义草稿文件。

Boolean

offlineTarget

(读取和写入)

将发布服务定义的目标服务器版本。 指定一个版本可确保服务定义包含与服务器兼容的内容。 仅在属性 offline 设置为 True 时支持此属性。

  • ENTERPRISE_10x - 内容将与 ArcGIS Server 10.9.1 或较早版本兼容。 这是默认设置。

  • ENTERPRISE_11 - 内容将与 ArcGIS Server 11.0 或更高版本兼容。

String

overwriteExistingService

(读取和写入)

指定是否覆盖具有相同名称的现有服务。

Boolean

pooling.maxInstances

(读取和写入)

每台计算机的最大实例数 仅在属性 pooling.type 设置为 DEDICATED 时支持此属性。

Integer

pooling.minInstances

(读取和写入)

每台计算机的最小实例数: 仅在属性 pooling.type 设置为 DEDICATED 时支持此属性。

Integer

pooling.type

(读取和写入)

将使用的实例池化的类型。

  • SHARED

  • DEDICATED

String

serverFolder

(读取和写入)

服务将发布到的服务器文件夹的名称。 默认文件夹是服务器的根文件夹。 如果不存在此文件夹,则会进行创建。

String

serverType

(只读)

通过 CreateSharingDraft 函数创建 MapServiceDraft 时指定的服务器类型。 从 serverType 的 MapServiceDraft 中返回的唯一可能的值为 STANDALONE_SERVER 。 serverType 的 STANDALONE_SERVER 表示支持为 ArcGIS Server 创建地图服务。

String

serviceName

(读取和写入)

地图服务的名称。 用户可以看到该名称并使用该名称来识别服务。 名称只能包含字母数字字符和下划线。 不允许使用空格或特殊字符。 名称不能超过 120 个字符。

String

summary

(读取和写入)

地图服务的摘要。

String

tags

(读取和写入)

地图服务的标签。 多个标签可以用逗号分隔。

String

targetServer

(读取和写入)

将发布地图的服务器。 可以使用以下任一格式指定此服务器:

  • ArcGIS Server 连接文件 (.ags) 的完整路径。

  • ArcGIS Server URL。 如果您在 ArcGIS Pro 工程中拥有 ArcGIS Server 的 发布者或管理员连接 ,且您要在脚本中打开此工程或在 ArcGIS Pro 中运行脚本,请使用此选项。

有关详细信息,请参阅 连接到 GIS 服务器 。

提示:

该属性也可以在 上传服务定义 工具中的 in_server 参数中使用。

String

timezone.DaylightSavingTime

(读取和写入)

指定时区是否考虑夏令时。 默认值为 False 。

Boolean

timezone.ID

(读取和写入)

将存储日期值的时区。 字符串值必须与 Windows 操作系统识别的官方时区 ID 之一匹配。 有关时区的列表,请参阅 Microsoft 文档中的 时区 。

注:

该设置适用于以下情景:

  • 您的数据已设置编辑器追踪字段以记录数据库时间中的日期。

  • 您正在将包含日期字段的数据共享到 ArcGIS Enterprise 11.5 和更低版本。

  • 您正在共享至 ArcGIS Online 或 ArcGIS Enterprise 12.0 及更高版本,并且 图层属性 中未定义时区。

String

useLimitations

(读取和写入)

地图服务的使用限制。

String

方法

exportToSDDraft(out_sddraft)

将 MapServiceDraft 转换为服务定义草稿 (.sddraft) 文件。

名称 说明 数据类型

out_sddraft

输出服务定义草稿 (.sddraft) 文件的路径和文件名。

String

代码示例

将地图服务发布至服务器文件夹

以下脚本将为 地图服务 创建地图服务定义草稿文件 (.sddraft),并设置元数据属性。 地图服务将发布到独立 ArcGIS Server 站点中的文件夹。

import arcpy
import os

# Set output file names
outdir = r"C:\Project\Output"
service_name = "MapServiceDraftExample"
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)

# Reference map to publish
aprx = arcpy.mp.ArcGISProject(r"C:\Project\World.aprx")
m = aprx.listMaps('World')[0]

# Create MapServiceDraft and set metadata and server folder properties
target_server_connection = r"C:\Project\gisserver.ags.esri.com (publisher).ags"
sddraft = arcpy.sharing.CreateSharingDraft("STANDALONE_SERVER", "MAP_SERVICE", service_name, m)
sddraft.targetServer = target_server_connection
sddraft.credits = "These are credits"
sddraft.description = "This is description"
sddraft.summary = "This is summary"
sddraft.tags = "tag1, tag2"
sddraft.useLimitations = "These are use limitations"
sddraft.serverFolder = "MyServerFolder"

# Create Service Definition Draft file
sddraft.exportToSDDraft(sddraft_output_filename)

# Stage Service
print("Start Staging")
arcpy.server.StageService(sddraft_output_filename, sd_output_filename)

# Publish to server
print("Start Uploading")
arcpy.server.UploadServiceDefinition(sd_output_filename, target_server_connection)

print("Finish Publishing")
覆盖地图服务

以下脚本将 覆盖地图服务 。 如果服务名称已存在,则将覆盖该服务。 否则,将创建新服务。 如果希望地图服务具有特定的属性,则必须设置属性值,即使要覆盖的地图服务已配置了属性。 否则,现有属性将被默认设置覆盖。

import arcpy
import os

# Set output file names
outdir = r"C:\Project\Output"
service_name = "MapServiceDraftExample"
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)

# Reference map to publish
aprx = arcpy.mp.ArcGISProject(r"C:\Project\World.aprx")
m = aprx.listMaps('World')[0]

# Create MapServiceDraft and set overwrite property
target_server_connection = r"C:\Project\gisserver.ags.esri.com (publisher).ags"
sddraft = arcpy.sharing.CreateSharingDraft("STANDALONE_SERVER", "MAP_SERVICE", service_name, m)
sddraft.targetServer = target_server_connection
sddraft.overwriteExistingService = True

# Create Service Definition Draft file
sddraft.exportToSDDraft(sddraft_output_filename)

# Stage Service
print("Start Staging")
arcpy.server.StageService(sddraft_output_filename, sd_output_filename)

# Publish to server
print("Start Uploading")
arcpy.server.UploadServiceDefinition(sd_output_filename, target_server_connection)

print("Finish Publishing")
发布具有要素服务的地图服务

以下脚本将为引用注册数据的地图服务创建服务定义草稿文件 (.sddraft)。 必须已在服务器上注册数据存储,才能引用数据。 然后启用要素功能并设置地图服务和要素服务属性。 然后,会将修改后的 .sddraft 文件过渡并发布到 ArcGIS Server。

import arcpy
import os

# Set output file names
outdir = r"C:\Project\Output"
service_name = "MapServiceDraftExample"
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)

# Reference map to publish
aprx = arcpy.mp.ArcGISProject(r"C:\Project\World.aprx")
m = aprx.listMaps('World')[0]

# Create MapServiceDraft and set copyDataToServer property to false to reference registered data
target_server_connection = r"C:\Project\gisserver.ags.esri.com (publisher).ags"
sddraft = arcpy.sharing.CreateSharingDraft("STANDALONE_SERVER", "MAP_SERVICE", service_name, m)
sddraft.targetServer = target_server_connection
sddraft.copyDataToServer = False
sddraft.mapOperations = "Map,Data"
sddraft.extension.feature.isEnabled = True
sddraft.extension.feature.featureCapabilities = "Create,Sync,Query"

# Create Service Definition Draft file
sddraft.exportToSDDraft(sddraft_output_filename)

# Stage Service
print("Start Staging")
arcpy.server.StageService(sddraft_output_filename, sd_output_filename)

# Publish to server
print("Start Uploading")
arcpy.server.UploadServiceDefinition(sd_output_filename, target_server_connection)

print("Finish Publishing")
发布缓存地图服务

以下脚本通过调用 管理地图服务器缓存切片 工具以创建地图服务缓存切片,来发布缓存地图服务。

import arcpy
import os

# Set output file names
outdir = r"C:\Project\Output"
service_name = "MapServiceDraftExample"
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)

# Reference map to publish
aprx = arcpy.mp.ArcGISProject(r"C:\Project\World.aprx")
m = aprx.listMaps('World')[0]

# Create MapServiceDraft
target_server_connection = r"C:\Project\gisserver.ags.esri.com (publisher).ags"
sddraft = arcpy.sharing.CreateSharingDraft("STANDALONE_SERVER", "MAP_SERVICE", service_name, m)
sddraft.targetServer = target_server_connection
sddraft.enableCache = True

# Create Service Definition Draft file
sddraft.exportToSDDraft(sddraft_output_filename)

try:
    # Stage Service
    print("Start Staging")
    arcpy.server.StageService(sddraft_output_filename, sd_output_filename)
    warnings = arcpy.GetMessages(1)
    print(warnings)

    # Publish to server
    print("Start Uploading")
    arcpy.server.UploadServiceDefinition(sd_output_filename, target_server_connection)
    print("Finish Publishing")

    # Manage Map server Cache Tiles
    # For cache, use multiple scales separated by semicolon (;)
    # For example, "591657527.591555;295828763.795777"
    arcpy.server.ManageMapServerCacheTiles(target_server_connection + os.sep + service_name + ".MapServer", "591657527.591555", "RECREATE_ALL_TILES")
except Exception as stage_exception:
    print("Analyzer errors encountered - {}".format(str(stage_exception)))

except arcpy.ExecuteError:
    print(arcpy.GetMessages(2))
发布从现有缓存中提取的地图服务

以下脚本将为地图服务创建服务定义草稿文件 (.sddraft),并使用现有缓存绘制服务。 然后,会将修改后的 .sddraft 文件过渡并发布到 ArcGIS Server。

import arcpy
import os

# Set output file names
outdir = r"C:\Project\Output"
service_name = "MapServiceDraftExample"
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)

# Reference map to publish
aprx = arcpy.mp.ArcGISProject(r"C:\Project\World.aprx")
m = aprx.listMaps('World')[0]

# Create MapServiceDraft
target_server_connection = r"C:\Project\gisserver.ags.esri.com (publisher).ags"
sddraft = arcpy.sharing.CreateSharingDraft("STANDALONE_SERVER", "MAP_SERVICE", service_name, m)
sddraft.targetServer = target_server_connection
sddraft.enableCache = True
sddraft.cache.useExistingCache = True

# Create Service Definition Draft file
sddraft.exportToSDDraft(sddraft_output_filename)

# Stage Service
print("Start Staging")
arcpy.server.StageService(sddraft_output_filename, sd_output_filename)

# Publish to server
print("Start Uploading")
arcpy.server.UploadServiceDefinition(sd_output_filename, target_server_connection)

print("Finish Publishing")
分析并注册数据存储

以下脚本将为地图服务创建服务定义草稿文件 (.sddraft)。 在过渡期间,将对服务定义草稿文件进行分析。 如果返回分析器 24011 ,警告未将数据源注册到服务器,则将使用 AddDataStoreItem 函数注册数据存储。

import arcpy
import os

arcpy.env.overwriteOutput = True

# Set output file names
outdir = r"C:\Project\Output"
service_name = "MapServiceDraftExample"
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)

# Reference map to publish
aprx = arcpy.mp.ArcGISProject(r"C:\Project\World.aprx")
m = aprx.listMaps('World')[0]

# Create MapServiceDraft and set copyDataToServer property to False to reference registered data
target_server_connection = r"C:\Project\gisserver.ags.esri.com (publisher).ags"
sddraft = arcpy.sharing.CreateSharingDraft("STANDALONE_SERVER", "MAP_SERVICE", service_name, m)
sddraft.targetServer = target_server_connection
sddraft.copyDataToServer = False

# Create Service Definition Draft file
sddraft.exportToSDDraft(sddraft_output_filename)

# Stage the service and analyze the .sddraft file for registered data store
# Continue publishing only if data store is registered
print("Start Staging")
stage_service = True
while stage_service:
    arcpy.server.StageService(sddraft_output_filename, sd_output_filename)
    # Get analyzer warnings to check if data store is registered
    warnings = arcpy.GetMessages(1)
    print(warnings)
    # If data store is not registered
    if "24011" in warnings:
        # Register data store
        db_conn = r"C:\Project\db_conn.sde"
        register_msg = arcpy.AddDataStoreItem(target_server_connection, "DATABASE", "datastore_name", db_conn)
        print("Registered datastore: {0}".format(register_msg))
        # Stage the service again
        stage_service = True
    else:
        stage_service = False

# Publish to server
print("Start Uploading")
arcpy.server.UploadServiceDefinition(sd_output_filename, target_server_connection)

print("Finish Publishing")
设置时区并配置池化

以下脚本将为地图服务创建服务定义草稿文件 (.sddraft)。 必须已在服务器上注册数据存储,才能引用数据。 它为带有日期字段的图层设置时区,并配置服务实例设置。 然后,会将修改后的 .sddraft 文件过渡并发布到 ArcGIS Server。

import arcpy
import os
import codecs

# Set output file names
outdir = r"C:\Project\Output"
service_name = "MapServiceDraftExample"
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)

# Reference map to publish
aprx = arcpy.mp.ArcGISProject(r"C:\Project\World.aprx")
m = aprx.listMaps('World')[0]

# Create MapServiceDraft and set copyDataToServer property to False to reference registered data, set time zone, and configure pooling options
target_server_connection = r"C:\Project\gisserver.ags.esri.com (publisher).ags"
sddraft = arcpy.sharing.CreateSharingDraft("STANDALONE_SERVER", "MAP_SERVICE", service_name, m)
sddraft.targetServer = target_server_connection
sddraft.copyDataToServer = False
sddraft.timezone.ID = "Pacific Standard Time"
sddraft.timezone.DaylightSavingTime = True
sddraft.extension.feature.isEnabled = True
sddraft.pooling.type = "DEDICATED"
sddraft.pooling.minInstances = 0
sddraft.pooling.maxInstances = 2
sddraft.exportToSDDraft(sddraft_output_filename)

# Stage Service
print("Start Staging")
arcpy.server.StageService(sddraft_output_filename, sd_output_filename)

# Publish to server
print("Start Uploading")
arcpy.server.UploadServiceDefinition(sd_output_filename, target_server_connection)

print("Finish Publishing")
创建并发布离线服务定义

以下脚本将为目标服务器版本创建 离线服务定义 ,并将其发布为地图服务。

import arcpy
import os

# Set output file names
outdir = r"C:\Project\Output"
service_name = "MapServiceDraftExample"
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)

# Reference map to publish
aprx = arcpy.mp.ArcGISProject(r"C:\Project\World.aprx")
m = aprx.listMaps('World')[0]

# Create MapServiceDraft and set offline and offlineTarget properties
# The targetServer property is not needed when the offline property is set to True
sddraft = arcpy.sharing.CreateSharingDraft("STANDALONE_SERVER", "MAP_SERVICE", service_name, m)
sddraft.offline = True
# Set offlineTarget property to "ENTERPRISE_11" for ArcGIS Server 11.0 or later
# The default is ArcGIS Server 10.9.1 or earlier
sddraft.offlineTarget = "ENTERPRISE_10x"

# Create Service Definition Draft file
sddraft.exportToSDDraft(sddraft_output_filename)

# Stage Service
print("Start Staging")
arcpy.server.StageService(sddraft_output_filename, sd_output_filename)

# Publish to server
print("Start Uploading")
arcpy.server.UploadServiceDefinition(sd_output_filename, r"C:\Project\gisserver.ags.esri.com (publisher).ags")

print("Finish Publishing")
分析以确认地图已设置为允许分配唯一数字 ID

以下脚本将为 地图服务 创建用于启用 checkUniqueIDAssignment 属性的服务定义草案文件 (.sddraft)。 在过渡期间,将对服务定义草稿文件进行分析。 如果地图未设置为允许分配用于共享 web 图层的唯一数字 ID,则会返回分析器错误 00374 并打印一条消息。 有关详细信息,请参阅 分配图层 ID 。

import arcpy
import os

# Set output file names
outdir = r"C:\Project\Output"
service_name = "MapServiceDraftExample"
sddraft_filename = service_name + ".sddraft"
sddraft_output_filename = os.path.join(outdir, sddraft_filename)
sd_filename = service_name + ".sd"
sd_output_filename = os.path.join(outdir, sd_filename)

# Reference map to publish
aprx = arcpy.mp.ArcGISProject(r"C:\Project\World.aprx")
m = aprx.listMaps('World')[0]

# Create MapServiceDraft and set the check unique ID assignment property
target_server_connection = r"C:\Project\gisserver.ags.esri.com (publisher).ags"
sddraft = arcpy.sharing.CreateSharingDraft("STANDALONE_SERVER", "MAP_SERVICE", service_name, m)
sddraft.targetServer = target_server_connection
sddraft.checkUniqueIDAssignment = True

# Create Service Definition Draft file
sddraft.exportToSDDraft(sddraft_output_filename)

try:
    # Stage Service
    print("Start Staging")
    arcpy.server.StageService(sddraft_output_filename, sd_output_filename)
    # Share to portal
    print("Start Uploading")
    arcpy.server.UploadServiceDefinition(sd_output_filename, server_type)

    print("Finish Publishing")
except Exception as stage_exception:
    if "00374" in str(stage_exception):
        print("The map is not set to allow assignment of unique IDs")
    print("Analyzer errors encountered - {}".format(str(stage_exception)))

except arcpy.ExecuteError:
    print(arcpy.GetMessages(2))