Skip to main content
Solved

folder existance checker


Forum|alt.badge.img

Hello,

I am trying to use Python caller to check if a folder exist. Here is the code:

But it doesnt geve back outcome to attribute "van". Where is my mistake?

import fme
import fmeobjects
import os

def processFeature(feature):
    van = os.path.isdir(feature.getAttribute('_LAS_eleresiutvonal'))
    print van
    feature.setAttribute('_van', van)
class FeatureProcessor(object):
    def __init__(self):
        pass
    def input(self,feature):   
        self.pyoutput(feature)
    def close(self):
        pass

Best answer by ebygomm

The bit in yellow needs to be set to match the bit in red so processFeature

You are calling a class that doesn't exist

View original
Did this help you find an answer to your question?

11 replies

ebygomm
Influencer
Forum|alt.badge.img+33
  • Influencer
  • March 23, 2020

What version of python are you using? That code won't work for python 3

Have you enterd _van in the Attributes to Expose parameter


Forum|alt.badge.img
  • Author
  • March 23, 2020
ebygomm wrote:

What version of python are you using? That code won't work for python 3

Have you enterd _van in the Attributes to Expose parameter

I tried it but it gives back missing values :


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • March 23, 2020

Is your class or function to process features set to processFeature (good) or FeatureProcessor (bad in this case)?


ebygomm
Influencer
Forum|alt.badge.img+33
  • Influencer
  • March 23, 2020
gylona wrote:

I tried it but it gives back missing values :

Is everything else set up exactly as the screenshot?


Forum|alt.badge.img
  • Author
  • March 23, 2020
ebygomm wrote:

Is everything else set up exactly as the screenshot?

everything is okay, only python output is missing


david_r
Celebrity
  • March 23, 2020

In the above code, the lines 9-15 are not (should not be) used. Try deleting these lines and see if you get a different error message.


Forum|alt.badge.img
  • Author
  • March 23, 2020
david_r wrote:

In the above code, the lines 9-15 are not (should not be) used. Try deleting these lines and see if you get a different error message.

I deleted, now it says:

 

 

PythonFactory failed to load python symbol `FeatureProcessor'
Factory proxy not initialized
PythonCaller(PythonFactory): PythonFactory failed to process feature

ebygomm
Influencer
Forum|alt.badge.img+33
  • Influencer
  • March 23, 2020
gylona wrote:

everything is okay, only python output is missing

If you look at the screenshot, you will see that class or Function to process feature is set to processFeature, and the additional unwanted code is deleted. If you set up your pythoncaller exactly as posted it will work

ebygomm
Influencer
Forum|alt.badge.img+33
  • Influencer
  • Best Answer
  • March 23, 2020

The bit in yellow needs to be set to match the bit in red so processFeature

You are calling a class that doesn't exist


Forum|alt.badge.img
  • Author
  • March 23, 2020
ebygomm wrote:
If you look at the screenshot, you will see that class or Function to process feature is set to processFeature, and the additional unwanted code is deleted. If you set up your pythoncaller exactly as posted it will work

I got it, it works well ;)


david_r
Celebrity
  • March 23, 2020
gylona wrote:

I deleted, now it says:

 

 

PythonFactory failed to load python symbol `FeatureProcessor'
Factory proxy not initialized
PythonCaller(PythonFactory): PythonFactory failed to process feature

Thanks, now we see the real error. Do as suggested by @ebygomm and it should work.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings