import arcpy from arcpy import env import arcgisscripting env.workspace = "C:\Documents and Settings\longs\Application Data\ESRI\Desktop10.0\ArcCatalog\SpatialVegMgmt_NT38.sde.DEFAULT" tableset = "Actions, BioAgents, Density, Directions, Inspectors, MethodContacted, ROW, Units, weedFollowups, Weeds, WeedTypeRelate, WeedTypes, VegetationMgmt.GIS_SDE.weedIncidents" replica_type = "CHECK_OUT" output_workspace = "c:\usr_proj\ArcGIS\FileGeodatabases\Weed\Mark\WeedIncidents_FileGDB.gdb" replica_name = "MarkReplica" access_type = "FULL" initial_sender = "PARENT_DATA_SENDER" expand = "USE_DEFAULTS" reuse_schema = "DO_NOT_REUSE" get_related = "GET_RELATED" arcpy.MakeTableView_management("Database Connections\SpatialVegMgmt_NT38.sde\VegetationMgmt.owner.Actions", "Actions", "AID > 0") arcpy.MakeTableView_management("Database Connections\SpatialVegMgmt_NT38.sde\VegetationMgmt.owner.WEEDFOLLOWUPS", "WEEDFOLLOWUPS", "ObjectID > 0") arcpy.MakeTableView_management("Database Connections\SpatialVegMgmt_NT38.sde\VegetationMgmt.owner.Density", "Density", "DID > 0") arcpy.MakeTableView_management("Database Connections\SpatialVegMgmt_NT38.sde\VegetationMgmt.owner.Directions", "Directions", "GDID > 0") arcpy.MakeTableView_management("Database Connections\SpatialVegMgmt_NT38.sde\VegetationMgmt.owner.Inspectors", "Inspectors", "IID > 0") arcpy.MakeTableView_management("Database Connections\SpatialVegMgmt_NT38.sde\VegetationMgmt.owner.MethodContacted", "MethodContacted", "MCID > 0") arcpy.MakeTableView_management("Database Connections\SpatialVegMgmt_NT38.sde\VegetationMgmt.owner.ROW", "ROW", "ROWID > 0") arcpy.MakeTableView_management("Database Connections\SpatialVegMgmt_NT38.sde\VegetationMgmt.owner.Units", "Units", "UID > 0") arcpy.MakeTableView_management("Database Connections\SpatialVegMgmt_NT38.sde\VegetationMgmt.owner.Weeds", "Weeds", "WID > 0") arcpy.MakeTableView_management("Database Connections\SpatialVegMgmt_NT38.sde\VegetationMgmt.owner.WeedTypeRelate", "WeedTypeRelate", "ObjectID > 0") arcpy.MakeTableView_management("Database Connections\SpatialVegMgmt_NT38.sde\VegetationMgmt.owner.WeedTypes", "WeedTypes", "WTID > 0") arcpy.MakeTableView_management("Database Connections\SpatialVegMgmt_NT38.sde\VegetationMgmt.owner.BioAgents", "BioAgents", "BAID > 0") # Execute CreateReplica arcpy.CreateReplica_management(tableset, replica_type, output_workspace, replica_name, access_type, initial_sender, expand, reuse_schema, get_related)
tableset = "Database Connections\SpatialVegMgmt_NT38.sde\VegetationMgmt.owner.weedIncidents;Actions;BioAgents;Density;Directions;Inspectors;MethodContacted;ROW;Units;weedFollowups;Weeds;WeedTypeRelate;WeedTypes;FollowUpActivities"
Are you running Windows 7 64-bit? I found a bug regarding this:
NIM073906: Cannot run Create Replica as a script on a Windows 7 64-bit machine.
I am experiencing this issue on a Windows 7 64-bit machine. As this bug was found in version 10.0 SP2 and I am running version 10.2, any idea when this bug will be fixed? I have 45 geodatabases to create replicas for and doing it outside of a script (manually through ArcToolbox or ArcMap, which works) is not really an option.
Thanks!
C:\Python27\ArcGIS10.1\python.exe "locationAndNameOfYourScript" ArgumentsForYourScript Example: C:\Python27\ArcGIS10.1\python.exe \\oly\gisshare\Projects\con\Depts\19864\WeedTools\scripts10_1\production\NightlySyncReplica.py -s SQLGIS1 -x rep
I am experiencing this issue on a Windows 7 64-bit machine. As this bug was found in version 10.0 SP2 and I am running version 10.2, any idea when this bug will be fixed? I have 45 geodatabases to create replicas for and doing it outside of a script (manually through ArcToolbox or ArcMap, which works) is not really an option.
Thanks!
I am still having trouble with this. I am using:
ArcGIS 10.2.2 with Python 2.7 (installed through ArcGIS)
Windows 7 64-bit machine
SQL Server Express 2012 (Workgroup SDE, NOT Enterprise)
Pythonwin site-package for Python 2.7
I am using the 32-bit Python interpreter:
PythonWin 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32.
Below is the Traceback from the arcpy.CreateReplica_management line in my script:
Traceback (most recent call last):
File "C:\WorkSpace\tools\scripts\CreateTNF1WayReplica\R10Create1wayReplica2fGDBNAS_10_2.py", line 157, in makeReplica
arcpy.CreateReplica_management(featureList, "ONE_WAY_REPLICA", outGDB, replicaName, "FULL", "PARENT_DATA_SENDER", "ALL_ROWS", "", "", "", "DO_NOT_USE_ARCHIVING")
File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\management.py", line 803, in CreateReplica
raise e
ExecuteError: ERROR 000582: Error occurred during execution.
So I stepped through in the debugger and stepped into the management.py script and also into the _base.py from there. Here is the point that the error occurs:
Traceback (most recent call last):
File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\management.py", line 800, in CreateReplica
retval = convertArcObjectToPythonObject(gp.CreateReplica_management(*gp_fixargs((in_data, in_type, out_geodatabase, out_name, access_type, initial_data_sender, expand_feature_classes_and_tables, reuse_schema, get_related_data, geometry_features, archiving), True)))
File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 498, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
ExecuteError: ERROR 000582: Error occurred during execution.
I stepped through the gp_fixargs and at line 40 of _base.py, my args turned into new_args as follows:
['"C:\\WorkSpace\\temp\\CreateReplicas\\inputs\\Activities.sde\\Activities.DBO.Activities\\Activities.DBO.ProjectArea;C:\\WorkSpace\\temp\\CreateReplicas\\inputs\\Activities.sde\\Activities.DBO.Activities\\Activities.DBO.TMCompartment;C:\\WorkSpace\\temp\\CreateReplicas\\inputs\\Activities.sde\\Activities.DBO.Activities\\Activities.DBO.ActivityPoint;C:\\WorkSpace\\temp\\CreateReplicas\\inputs\\Activities.sde\\Activities.DBO.Activities\\Activities.DBO.CoverType;C:\\WorkSpace\\temp\\CreateReplicas\\inputs\\Activities.sde\\Activities.DBO.Activities\\Activities.DBO.ValueComparisonUnit;C:\\WorkSpace\\temp\\CreateReplicas\\inputs\\Activities.sde\\Activities.DBO.Activities\\Activities.DBO.ActivityPolygon;C:\\WorkSpace\\temp\\CreateReplicas\\inputs\\Activities.sde\\Activities.DBO.Activities\\Activities.DBO.ActivityLine;C:\\WorkSpace\\temp\\CreateReplicas\\inputs\\Activities.sde\\Activities.DBO.Activities\\Activities.DBO.CoverType_Topology;C:\\WorkSpace\\temp\\CreateReplicas\\inputs\\Activities.sde\\Activities.DBO.Activities\\Activities.DBO.VCU_TMComp_Topology"', 'ONE_WAY_REPLICA', '\\\\199.131.000.000\\TNFRef\\GISData\\Activities.gdb', 'Activities_1WayRO2NAS', 'FULL', 'PARENT_DATA_SENDER', 'ALL_ROWS', '', '', '', 'DO_NOT_USE_ARCHIVING']
Every once in a while I can get this to work but can't find rhyme or reason as to why it works every once in a while. I have tried the output file geodatabase location on my C: drive ('C:\\WorkSpace\\temp\\CreateReplicas\\outputs\\gdbs\\Activities.gdb'), on the external share mapped as UNC path (as above: '\\\\199.131.000.000\\TNFRef\\GISData\\Activities.gdb'), and mapped as a drive letter ('Y:\\GISData\\Activities.gdb'), all with the same results (Error 00582).
[The IP address has been changed to 0s on purpose for posting here, it is the real IP address in the script.]
Attached is the code block from my script, with inputs being:
parentGDS = Database connection .sde file on C: drive that points to our Workgroup SDE instance for the database in the list of databases (in this case, "Activities")
GDBPath = the output location for the file GDB to be stored. I have tried local C: drive and our NAS drive as UNC and mapped as a drive letter
gdbName = the name of the database in the list. In this case "Activities"
If the output geodatabase (in this case Activities.gdb) does not exist, it is created before getting to the create replica part, using:
if not arcpy.Exists(outGDBPath + os.sep + gdbName):
createTargetGDB(outGDBPath,gdbName)
I tried running it in ArcMap, using the Create Replica tool in Toolbox and got the following:
Executing: CreateReplica Activities.DBO.CoverType_Topology;Activities.DBO.VCU_TMComp_Topology;ActivityPoint;ActivityLine;ProjectArea;Activities.DBO.TMCompartment;CoverType;Activities.DBO.ValueComparisonUnit;ActivityPolygon ONE_WAY_REPLICA C:\WorkSpace\temp\CreateReplicas\outputs\gdbs\Activities.gdb ArcMapToolboxTest FULL PARENT_DATA_SENDER ALL_ROWS DO_NOT_REUSE GET_RELATED # DO_NOT_USE_ARCHIVING
Start Time: Wed Oct 28 15:12:27 2015
Executing CreateReplica...
ERROR 000582: Error occurred during execution.
Failed to execute (CreateReplica).
Is there any way to tell which input parameter is causing the error? Could this still be a bug in the GP tool? I'm about to go to ArcObjects and write a C#.NET executable to do the replica creation like I used to before I thought Bug NIM-073906 was fixed (http://support.esri.com/en/bugs/nimbus/TklNMDczOTA2).
The Create Replica tool has more usage footnotes, possibly the most, that I have seen for a tool. Some of the usage notes get into the weeds, e.g., "data that you wish to replicate must be versioned, but not with the option to move edits to base." Given there are 16 notes and sub-notes, it never hurts to go back and double check them all.
Beyond verifying all of the conditions to run the tool have been met, the specific error (000582) can crop up when the validation process for a tool's parameter values fails. Let's look at one of your calls to the tool:
#include parameter names and requirement status as comments arcpy.CreateReplica_management(featureList, # in_data (required) "ONE_WAY_REPLICA", # in_type (required) outGDB, # out_geodatabase (required) replicaName, # out_name (required) "FULL", # access_type (optional) "PARENT_DATA_SENDER", # initial_data_sender (optional) "ALL_ROWS", # expand_feature_classes_and_tables (opt) "", # reuse_schema (optional) "", # get_related_data (optional) "", # geometry_features (optional) "DO_NOT_USE_ARCHIVING") # archiving (optional ?)
While most geoprocessing tools include the default argument for optional parameters in the syntax table, the Create Replica documentation only provides that information for half of the optional parameters, which is not only unfortunate but a documentation bug in my eyes. What is even more odd, and another documentation bug, is that archiving isn't stated to be optional but yet it is at the end of the parameter list (required parameters can't come after optional ones) and a default argument is stated.
Getting back to the example at hand, I strongly discourage passing empty strings to optional parameters. Unless the default argument is an empty string or the documentation states empty strings are handled in a special way, passing an empty string will lead to the code/tool to bypass the default argument and use the empty string instead. It could very well be that passing "" to reuse_schema is causing the issue because the two arguments that parameter accepts are "DO_NOT_REUSE" and "REUSE" . Since it looks like you want defaults for the last 4 parameters, what is the result of trying the following:
#include parameter names and requirement status as comments arcpy.CreateReplica_management(featureList, # in_data (required) "ONE_WAY_REPLICA", # in_type (required) outGDB, # out_geodatabase (required) replicaName, # out_name (required) "FULL", # access_type (optional) "PARENT_DATA_SENDER", # initial_data_sender (optional) "ALL_ROWS") # expand_feature_classes_and_tables (opt)