Skip to main content
Solved

setting a parameter depending on the environment


vki
Contributor
Forum|alt.badge.img+7
  • Contributor

I want to set the value of an attribute, depending on the environment, where my workbench is running (desktop, server dev, server prd),. I could do this with an parameterFetcher and get e.g. FME_SERVER_HOST. But I don't want to do this for each feature, but just once at the beginning.

What's the best way to do this?

I tried it with a scripted parameter, but I get an error, for FME_SERVER_HOST is not know when I run the workbench on desktop.

Then I tried it with a startup-script. Here I don't get an error, but how can I set a parameter here, that I can use in the workbench?

Thanks, Vera

 

 

Best answer by takashi

A possible workaround is to create a Python scripted parameter like this.

import fme
return fme.macroValues.get('FME_SERVER_HOST''https://foo.com')
View original
Did this help you find an answer to your question?

5 replies

david_r
Evangelist
  • May 6, 2020

Try using something like the following in a scripted parameter:

import fme
host = fme.macroValues.get('FME_SERVER_HOST'None)
if host:
    # Running on FME Server
    return host
else:
    # Running on FME Desktop
    return 'development'

This will return the value of FME_SERVER_HOST if running on FME Server, or 'development' if running on FME Desktop.


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • Best Answer
  • May 6, 2020

A possible workaround is to create a Python scripted parameter like this.

import fme
return fme.macroValues.get('FME_SERVER_HOST''https://foo.com')

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • May 6, 2020
takashi wrote:

A possible workaround is to create a Python scripted parameter like this.

import fme
return fme.macroValues.get('FME_SERVER_HOST''https://foo.com')

The approach is exactly same as @david_r's :-)


david_r
Evangelist
  • May 6, 2020
takashi wrote:

The approach is exactly same as @david_r's :-)

Indeed, yours is shorter but mine has comments :-)


vki
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • May 6, 2020

Great, thanks!


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