Skip to main content
Solved

Shutdown python using arcpy - arcpy.Exists() returns wrong result

  • July 4, 2017
  • 7 replies
  • 84 views

bgeorges
Contributor
Forum|alt.badge.img+5

Something very strange happen in my shutdown python script that uses arcpy.Exists() function. This function test if a feature class exists or not and returns True or False.

The following script returns False in FME even if the feature class do exists. I have tryed the same script in a python shell using the same python interpretor, and it returns True. 

Any ideas why it fails in FME shutdown python?

import arcpy

print arcpy.Exists("\\\\cnatrtd8\\geo\\GEODEV011.sde\\GEO09_WEB_MERCATOR\\GEO09E03_CS_STA")

Best answer by david_r

Just a hunch, could this maybe be related to the FME 2016 issue with PYTHONPATH and arcpy? It's kind of a long shot, but maybe worth a try:

# Fix pythonpath
import sys
sys.path.append(sys.path.pop(0))
sys.path.append(sys.path.pop(0))

# Business as usual from here
import arcpy
arcpy.env.workspace = r"\\cnatrtd8\geo\GEODEV011.sde"
print arcpy.Exists(r"GEO09_WEB_MERCATOR\GEO09E03_CS_STA")

More info here: https://knowledge.safe.com/questions/38010/arcgis-workspaces-in-fme.html

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

7 replies

david_r
Celebrity
  • July 4, 2017

I'm assuming this is all on FME Desktop, let us know if you've got FME Server in the mix.

What happens if you modify it like this:

import arcpy
arcpy.env.workspace = r"\\cnatrtd8\geo\GEODEV011.sde"
print arcpy.Exists(r"GEO09_WEB_MERCATOR\GEO09E03_CS_STA")

Tip: you can put an "r" in front of your string literals to avoid doubling your backslashes, see https://stackoverflow.com/a/4780104


bgeorges
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • July 4, 2017

Same results, it returns True in the python shell and False in the FME Shutdown script.

I am using FME 2016 1.3.2.

I have tryed with FME 2017, and curiously that solve that problem.

However, for other reasons, I have to stay with FME 2016 1.3.2 so I am in a dead end right now...


mark2atsafe
Safer
Forum|alt.badge.img+58

Hi @bgeorges

I checked and can't see a specific Python fix in 2017 that was for boolean values, but I did find one for Java. If our Python scripts are just a wrapper for Java (I have no idea) that might explain the fix in 2017.

If (in that case) you read a false value as a boolean:

getAttributeBoolean("TestFalse")

It would return true! However, it returned false if you read the value as a string:

getAttributeString("TestFalse")

So that was a workaround there.

Is that anything that helps you? Besides that I can't think of any way to have something work in 2016. The best thing there would be to contact our support team (safe.com/support) and ask them to talk to the Python developers. If it's related to the issue I mentioned, it would be PR#76735 and maybe PR#69395, so you could quote those references to them for a quicker response.

Hope this helps

Mark


david_r
Celebrity
  • Best Answer
  • July 6, 2017

Just a hunch, could this maybe be related to the FME 2016 issue with PYTHONPATH and arcpy? It's kind of a long shot, but maybe worth a try:

# Fix pythonpath
import sys
sys.path.append(sys.path.pop(0))
sys.path.append(sys.path.pop(0))

# Business as usual from here
import arcpy
arcpy.env.workspace = r"\\cnatrtd8\geo\GEODEV011.sde"
print arcpy.Exists(r"GEO09_WEB_MERCATOR\GEO09E03_CS_STA")

More info here: https://knowledge.safe.com/questions/38010/arcgis-workspaces-in-fme.html


bgeorges
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • July 6, 2017

Thank you David and Mark for your replies.

Doing more tests, I think the problem might be that arcpy is having problems to connect to the Geodatabase using a .sde connection file. arcpy.Exists() return false because the connection was not made. Other arcpy functions that tries to read or write to a feature class inside the Geodatabase are not working when called from FME while they work when called from a python shell.

The authentication type of the connection file is defined to: Database authentication, and the credentials are saved inside the .sde. I doubt that authentification is the cause of the problem here.

The Geodatabase Enterprise is using ArcGIS 10.3 and is installed on an Oracle 11g database.


bgeorges
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • July 6, 2017

Just a hunch, could this maybe be related to the FME 2016 issue with PYTHONPATH and arcpy? It's kind of a long shot, but maybe worth a try:

# Fix pythonpath
import sys
sys.path.append(sys.path.pop(0))
sys.path.append(sys.path.pop(0))

# Business as usual from here
import arcpy
arcpy.env.workspace = r"\\cnatrtd8\geo\GEODEV011.sde"
print arcpy.Exists(r"GEO09_WEB_MERCATOR\GEO09E03_CS_STA")

More info here: https://knowledge.safe.com/questions/38010/arcgis-workspaces-in-fme.html

That was the problem, thank you!

 

 


david_r
Celebrity
  • July 6, 2017
That was the problem, thank you!

 

 

Great to hear!