ListReplicas

摘要

列出工作空间中的复本。

说明

可以指定作为函数参数的连接文件的路径,或为连接文件设置工作空间环境并调用不带任何参数的 ListReplicas 函数。

语法

ListReplicas (workspace, {all_replicas})
参数说明数据类型
workspace

地理数据库工作空间。

String
all_replicas

指定是否返回地理数据库中的所有复本类型。

  • True - 返回所有复本类型。这可能包括 ReplicaSyncReplica 对象。
  • False - 仅返回 Replica 对象。其中包括从地理数据库复制工作流创建的复本,以及通过在传统版本化数据上运行的要素服务创建的复本。这是默认设置。

(默认值为 False)

Boolean
返回值
数据类型说明
Replica

从包含 Replica 对象的函数返回的列表。

如果 all_replicas 参数已设置为 True,则也可能会返回 SyncReplica 对象。

代码示例

ListReplicas 示例 1

为作为发送方的工作空间中的各个复本调用 ExportDataChangeMessage 函数。

import arcpy
import os
sdeConnection = "C:/Data/toolboxDEFAULTVersion.sde"
outLocation = "C:/data"
for replica in arcpy.da.ListReplicas(sdeConnection):
    # If the replica is a sender, call ExportDataChangeMessage
    if replica.isSender:
        changesFile = os.path.join(outputLocation,
                                   "changes_{0}.gdb".format(replica.name))
        arcpy.ExportDataChangeMessage_management(sdeConnection,
                                                 changes,
                                                 replica.name)
ListReplicas 示例 2

打印所有存在冲突的复本。

import arcpy
sdeConnection = "C:/Data/toolboxDEFAULTVersion.sde"
# Print the name of the replicas that are in conflict
#
for replica in arcpy.da.ListReplicas(sdeConnection):
    if replica.hasConflicts:
        print(replica.name)
ListReplicas 示例 3

打印 SyncReplica 对象的属性

# Import required modules
import arcpy
# Use the ListReplicas function to return all replicas in the geodatabase
replicas = arcpy.da.ListReplicas("C:\\Projects\\MyProject\\myGDB.sde", True)
for r in replicas:
    # Check if the class is a SyncReplica
    if isinstance(r, arcpy.da.SyncReplica):
        # Print the properties of a SyncReplica object
        print("Properties of replica named: {}".format(r.name))
        print("Datasets: {}".format(r.datasets))    
        print("Owner: {}".format(r.owner))
        print("Replica ID: {}".format(r.replicaID))
        print("Service name: {}".format(r.serviceName))
        print("Version: {}".format(r.version))
        print("Direction: {}".format(r.direction))
        print("Sync model: {}".format(r.syncModel))
        print("Last sync date: {}".format(r.lastSyncDate))
        print("LayerServerGens: {}".format(r.layerServerGens))
        print("LayerServerSibGens: {}".format(r.layerServerSibGens))
        print("ReplicaServerGen: {}".format(r.replicaServerGen))
        print("ReplicaServerSibGen: {}".format(r.replicaServerSibGen))
        print("Target type: {}".format(r.targetType))

相关主题


在本主题中