Skip to main content
Question

Getting User parameters with python is formatting input values weird


so_much_more
Supporter
Forum|alt.badge.img+6

I am writing a shutdown script to logg a workbench result to a postgres database.

To log the output location of a gpkg file I am fetching a public parameter like so fme.macroValues['dest_path']

But i get some weird formatting where backslash etc ar written as verbose text instead of the actual path? How can I get the actual path?

 

C:<backslash>Users<backslash>User<backslash>Documents<backslash>FME_proj<backslash>20230913_FME<backslash>WIP<solidus>output<backslash>myoutput.gpkg

 

3 replies

david_r
Evangelist
  • November 6, 2023

Try the following:

fmeobjects.FMESession().decodeFromFMEParsableText(fme.macroValues['dest_path'])

See also the documentation: https://docs.safe.com/fme/html/fmepython/api/fmeobjects/_utilities/fmeobjects.FMESession.decodeFromFMEParsableText.html#fmeobjects.FMESession.decodeFromFMEParsableText


so_much_more
Supporter
Forum|alt.badge.img+6
  • Author
  • Supporter
  • November 7, 2023

I tried but I got this error:

ERROR : An attempt was made to create a new FME Objects session while a translation is in the process of shutting down, possibly from a Python shutdown script. This is not a supportable operation

It works if use it in a python caller. 

I declared a global variable in the python caller that i used in the shut down script. A bit redundant and messy, but maybe thats the only way?


david_r
Evangelist
  • November 7, 2023
so_much_more wrote:

I tried but I got this error:

ERROR : An attempt was made to create a new FME Objects session while a translation is in the process of shutting down, possibly from a Python shutdown script. This is not a supportable operation

It works if use it in a python caller. 

I declared a global variable in the python caller that i used in the shut down script. A bit redundant and messy, but maybe thats the only way?

Looks like FME has become stricter about "abusing" the use of the fmeobjects module in the startup/shutdown script. I guess the best solution would be for Safe to move these helper functions out of the FMESession class and into a general utility class, but until then your workaround is probably necessary.


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