Skip to main content
Question

how to know the value of a output parameter

  • September 14, 2018
  • 5 replies
  • 10 views

Hello,

The problem is, I have a shutdown python script but I need the value of an output parameter, there's any way to know the value of that parameter "Division" with python?

5 replies

david_r
Evangelist
  • September 14, 2018

Not quite sure I understand... Do you need to acces the value of attribute "Division" from e.g. a PythonCaller? If so:

my_division_value = feature.getAttribute('Division')

david_r wrote:

Not quite sure I understand... Do you need to acces the value of attribute "Division" from e.g. a PythonCaller? If so:

my_division_value = feature.getAttribute('Division')
I'm new with python scripting in fme, with this said... yes, I need the value of attribute "Division" but I don't know if I need to use a PythonCaller or can be done without using the PythonCaller?

 

 


david_r
Evangelist
  • September 14, 2018
yaraapplerocks wrote:
I'm new with python scripting in fme, with this said... yes, I need the value of attribute "Division" but I don't know if I need to use a PythonCaller or can be done without using the PythonCaller?

 

 

Getting the value is the easy part, but what is it exactly that you want to accomplish? Knowing more would be helpful. But yes, basically you need the PythonCaller.

david_r wrote:
Getting the value is the easy part, but what is it exactly that you want to accomplish? Knowing more would be helpful. But yes, basically you need the PythonCaller.
ok, what I want to accomplish is to write a file with the value of the translation status (FAILED, SUCCESSFUL) and the value of the attribute "Division". My workspace starts with a SQL Creator and I don't know if this is important but one of the start parameters is "Division" and is the same value 'til the output, so I can get the value at the beginning or when the translation ends.

 


david_r
Evangelist
  • September 14, 2018

Thanks for the supplemental info. So you already know how to write a file with the translation status (see here).

The second part is how to "transfer" the value of a feature attribute into the shutdown script. We can use a Python global variable for that. Insert a PythonCaller just before the writer:

def GetDivisionValue(feature):
    global MY_GLOBAL_DIVISION_VALUE
    MY_GLOBAL_DIVISION_VALUE = feature.getAttribute('Division')

Then in the shutdown script, you can retrieve the global variable like this:

global MY_GLOBAL_DIVISION_VALUE
print "The Division value was:", MY_GLOBAL_DIVISION_VALUE

As it is, I assume that only a single feature will be written to Voting...-something writer.


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