Arcpy.CreateReplica Doesn't Work

527
2
Jump to solution
07-30-2019 09:37 AM
JordanMiller4
Occasional Contributor III

I am confused as to why the arcpy.CreateReplica doesn't work when my script gets a list of versioned layers and puts them into a variable to load into the function verses me hard coding versioned layer fields into the script and it working fine. Any ideas?

import arcpy
import os

# Local info
userName = os.environ.get( "USERNAME" )
pcVersion = "Desktop10.7"
in_data = ""

# Data connections
ws = r"C:\Users\%s\AppData\Roaming\ESRI\%s\ArcCatalog\server.sde" % (userName,pcVersion)
gdb = r"C:\Users\%s\AppData\Roaming\ESRI\%s\ArcCatalog\local.sde"  % (userName,pcVersion)
rName = r"TEST"# % (userName)
in_data = ""

arcpy.env.workspace = ws
dataList = arcpy.ListDatasets() + arcpy.ListFeatureClasses()
for dataset in dataList:
    desc = arcpy.Describe(dataset)
    if desc.isVersioned:
        if "__ATTACH" in desc.name:
            print ("Removing __ATTACH")
        elif "NEO.DBO.cities" in desc.name:
            print ("Removing NEO.DBO.cities")
        elif "NEO.DBO.P_AlignmentSheet_test" in desc.name:
            print ("Removing NEO.DBO.P_AlignmentSheet_test") 
        else:
            in_data = in_data + '"%s",' % (desc.name)
            print desc.name
    
in_data = in_data[:-1]
print in_data
try:
    arcpy.env.workspace = ws
    print("BuildReplica...")
    
    arcpy.CreateReplica_management(in_data, 'TWO_WAY_REPLICA',gdb,rName,'FULL','CHILD_DATA_SENDER',
                                   'USE_DEFAULTS','DO_NOT_REUSE','GET_RELATED', '','DO_NOT_USE_ARCHIVING')
    print("BuildReplica done")
except Exception:
    e = sys.exc_info()[1]
    print(e.args[0])

"NEO.SDE.ArchivedProposedMainline","NEO.SDE.Directory_Mwetzel","NEO.SDE.Misc_Companies","NEO.SDE.Misc_NEOFiles","NEO.SDE.Misc_OhioLayers","NEO.SDE.P_Integrity","NEO.SDE.P_PipeSystem","NEO.SDE.Parcels","NEO.SDE.Roads","NEO.SDE.TransmissionPipeline","NEO.SDE.StandaloneVersions","NEO.SDE.StandaloneLayers","NEO.SDE.Inspections","NEO.SDE.ArchivedLayers","NEO.SDE.P_AbandonedDevice","NEO.SDE.P_AbandonedPipe","NEO.SDE.P_AbandonedService","NEO.SDE.P_AlignmentSheet","NEO.SDE.P_CapitalProject","NEO.SDE.P_Coupon","NEO.SDE.P_CPArea","NEO.SDE.P_DrinkingWater","NEO.SDE.P_EcologicalArea","NEO.SDE.P_ExcavationDamage","NEO.SDE.P_ExposedPipeInspect","NEO.SDE.P_GasLeak","NEO.SDE.P_GasLeakInspect","NEO.SDE.P_IdentifiedIssue","NEO.SDE.P_LeakRepairs","NEO.SDE.P_LeakSurvey","NEO.SDE.P_LeakSurveyArea","NEO.SDE.P_NavigableWaterway","NEO.SDE.P_OtherPopulatedArea","NEO.SDE.P_OutsideArea","NEO.SDE.P_PipeCasing","NEO.SDE.P_PipeJobSeparator","NEO.SDE.P_PipelineMarker","NEO.SDE.P_REGULATORINSPECTION","NEO.SDE.P_SqueezeOff","NEO.SDE.P_StationStructure","NEO.SDE.P_StructureFootPrint","NEO.SDE.P_StructurePoint","NEO.SDE.P_Vault","NEO.SDE.P_WorkOrder","NEO.SDE.Atmospheric_Corrosion_Sites",
BuildReplica...
ERROR 000582: Error occurred during execution.
Failed to execute (CreateReplica).
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

The problem might be that in_data should be a list and not a string. You could change line 13 to be:

in_data = []

Then line 27 would be

in_data.append(desc.name)

And then comment out line 30 since you'll no longer need to slice the string.

View solution in original post

2 Replies
by Anonymous User
Not applicable

The problem might be that in_data should be a list and not a string. You could change line 13 to be:

in_data = []

Then line 27 would be

in_data.append(desc.name)

And then comment out line 30 since you'll no longer need to slice the string.

JordanMiller4
Occasional Contributor III

Thanks!

0 Kudos