Skip to main content
Solved

Startup Python Script - How to make python input() work?


robertr
Contributor
Forum|alt.badge.img+6

Hello,

 

I was initially running a python script outside FME to prompt a user for a said city to download data for.

 

I would like to integrate that script as a "Python Startup Script", in FME 2017.1. 

I am stuck right at the beginning where I want the user to mention the city but the input caller stops the progress of the translation and the console log is waiting for something I am not sure how to enter. It would be even cooler if I could present him a dropdown list to chose from.

county_name = input('City Name: ').title()

The log window shows the following:

FME_BEGIN_PYTHON: evaluating python script from string...
Enter the City Name:

...aaand I cannot do anything here. Or I am not aware of the input place.

Any advice on how to overcome this?

Best answer by mark_f

Hi - you need to use a Published Parameter - create one in the navigator panel. Then at runtime you can supply a value. Fetch this value into the startup script using

value = FME_MacroValues['MYCITY']

or

import fme
value = fme.macroValues['MYCITY']

where MYCITY is the name of the parameter created.

So you can create a Published Parameter as free text entry, but also create picklist and any other types of parameters.

0684Q00000ArLH8QAN.png

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

5 replies

Forum|alt.badge.img+2
  • Best Answer
  • January 8, 2018

Hi - you need to use a Published Parameter - create one in the navigator panel. Then at runtime you can supply a value. Fetch this value into the startup script using

value = FME_MacroValues['MYCITY']

or

import fme
value = fme.macroValues['MYCITY']

where MYCITY is the name of the parameter created.

So you can create a Published Parameter as free text entry, but also create picklist and any other types of parameters.

0684Q00000ArLH8QAN.png


robertr
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • January 8, 2018
mark_f wrote:

Hi - you need to use a Published Parameter - create one in the navigator panel. Then at runtime you can supply a value. Fetch this value into the startup script using

value = FME_MacroValues['MYCITY']

or

import fme
value = fme.macroValues['MYCITY']

where MYCITY is the name of the parameter created.

So you can create a Published Parameter as free text entry, but also create picklist and any other types of parameters.

0684Q00000ArLH8QAN.png

uuuhhh... I seeeee. Thanks @mark_1spatial!

 

There is huge potential in mastering this part. I will start looking in more depth into published and private parameters + link-ing them to this or that.

 

 

Do you happen to know a place where all these Python related features from FME are located? Here I mean all the stuff that comes when importing FME in python (like FME_MacroValues)

 

 

Is there anything else that you found helpful except this page: linktoDocumentation?

 


Forum|alt.badge.img+2
  • January 8, 2018
mark_f wrote:

Hi - you need to use a Published Parameter - create one in the navigator panel. Then at runtime you can supply a value. Fetch this value into the startup script using

value = FME_MacroValues['MYCITY']

or

import fme
value = fme.macroValues['MYCITY']

where MYCITY is the name of the parameter created.

So you can create a Published Parameter as free text entry, but also create picklist and any other types of parameters.

0684Q00000ArLH8QAN.png

Some good examples here:

 

https://knowledge.safe.com/articles/706/python-and-fme-basics.html

 

 

there is online help included for Python also. There are a number of members on this forum who are FME Python Jedi ;)

 

 


robertr
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • January 8, 2018
mark_f wrote:
Some good examples here:

 

https://knowledge.safe.com/articles/706/python-and-fme-basics.html

 

 

there is online help included for Python also. There are a number of members on this forum who are FME Python Jedi ;)

 

 

Good to hear!

 

One more question. I noticed that $MYCITY remains set to the option I selected in the 1st place.

 

When reopening the workspace, it does not prompt anymore although I did not select anything for "default" value. I always want it to prompt.

 

 

Laster Edit: convert to private and select "Prompt Before Running Workspace".

Forum|alt.badge.img+2
  • January 9, 2018
mark_f wrote:

Hi - you need to use a Published Parameter - create one in the navigator panel. Then at runtime you can supply a value. Fetch this value into the startup script using

value = FME_MacroValues['MYCITY']

or

import fme
value = fme.macroValues['MYCITY']

where MYCITY is the name of the parameter created.

So you can create a Published Parameter as free text entry, but also create picklist and any other types of parameters.

0684Q00000ArLH8QAN.png

 

Unfortunately that’s not possible and something that bugs me too! I raised this idea asking for this to be changed so feel free to go and vote for it at this link ;)r

 

 

https://knowledge.safe.com/idea/45682/published-parameter-no-default-value.html

 

 

 

 


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