Select to view content in your preferred language

ArcPY Replica

1411
10
Jump to solution
01-29-2018 11:33 AM
MauricioRamirez1
Emerging Contributor

I have two ArcGIS servers running on Linux with and Oracle instance on each.  The GIS servers sit behind a 3rd party hardware load balancer and each server has a feature service layer allowing edits.  Since we're sitting behind the load balancer, we don't know which server we will hit and as such need to replicate the data from one instance to the other.  I can manually push the changes but I need a way to push those changes automatically.  I was thinking an ArcPY script could be helpul so I used the model builder and then exported that to a python script.  The model runs fine, but the script won't run.  I get a runtime error 999999 Error Executing function.  There is a reference to a line in the file 

import arceditor

Also arceditor.py line 18, gp.setProduct("ArcEditor")

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

As suggested by Joshua... skip the license check in the script

import arcpy  # first line in the script

then see if it works.  Working inside modelbuilder or in a script tool, makes things easier.  If you are trying to run scripts without arc*whatever open then you have to be careful.  If you work in a shared license environment... ditto.

View solution in original post

0 Kudos
10 Replies
DanPatterson_Retired
MVP Emeritus

I don't use it but

http://pro.arcgis.com/en/pro-app/arcpy/functions/checkproduct.htm

I presume that it works in the model and not in the script is that there isn't an explicit check before you try to set.

Have a look at the code sample, and make sure you 'import arcpy', at one time modelbuilder left out that all important line in certain situations.

0 Kudos
MauricioRamirez1
Emerging Contributor

The modelbuilder had the arcpy import there.  I'll try the check license to see if that helps.

0 Kudos
DanPatterson_Retired
MVP Emeritus

As suggested by Joshua... skip the license check in the script

import arcpy  # first line in the script

then see if it works.  Working inside modelbuilder or in a script tool, makes things easier.  If you are trying to run scripts without arc*whatever open then you have to be careful.  If you work in a shared license environment... ditto.

0 Kudos
MauricioRamirez1
Emerging Contributor

I skipped the check and just issued the Synchronize command and it worked.  Thanks!

0 Kudos
MauricioRamirez1
Emerging Contributor

I added the check, and the license is not available.  How can that be?

0 Kudos
MauricioRamirez1
Emerging Contributor

it tells me it's not licensed.

0 Kudos
JoeBorgione
MVP Emeritus

Perhaps you could post the code here; I've had the same thing happen to me, and there a number of posts here on the forum that suggest that model to python can be finicky.  I use Arcpy to create check out replicas and to check them back in.

That should just about do it....
0 Kudos
MauricioRamirez1
Emerging Contributor

# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# SyncChanges.py
# Created on: 2018-01-29 13:24:42.00000
# (generated by ArcGIS/ModelBuilder)
# Description:
# ---------------------------------------------------------------------------

# Set the necessary product code
#import arceditor

# Import arcpy module
import arcpy


# Local variables:
arcgisA_replica_sde = "Database Connections\\arcgisA.replica.sde"
arcgisA_replica_sde__2_ = arcgisA_replica_sde
arcgisB_replica_sde__2_ = arcgisA_replica_sde
arcgisB_replica_sde = "Database Connections\\arcgisB.replica.sde"

if arcpy.CheckProduct("ArcEditor") == "Available":
msg = 'License is available'
print(msg)
# Process: Synchronize Changes
arcpy.SynchronizeChanges_management(arcgisA_replica_sde, "NPTacArea", arcgisB_replica_sde, "BOTH_DIRECTIONS", "IN_FAVOR_OF_GDB1", "BY_OBJECT", "DO_NOT_RECONCILE")
else:
msg = 'License is not available'
print(msg)

I added the check based on another response and I keep falling into the else branch

0 Kudos
DanPatterson_Retired
MVP Emeritus

You appear to be running this as a standalone script.

Add a toolbox, add the script and see if the script will run as a tool from within arctoolbox.

Otherwise, get your licensing checked, since you are working in a shared environment and it may not be available when arcmap isn't open.  Then there is that whole sde thing

0 Kudos