Skip to main content
Question

Scripted (Python) user parameter not working with writer (but is working with reader)


I successfully set up a Scripted (Python) Published Parameter called GIS_FILESHARE_ROOT. 

CaptureThe script has the following code:

import sys
sys.path.insert(0, FME_MacroValues['FME_MF_DIR'])
import config
return config.GIS_FILESHARE_ROOT

This imports config. Config is located in a subdirectory called 'config' of where the fmw lives. This subdirectory has an __init__.py file with the following code:

import os
GIS_FILESHARE_ROOT = os.path.abspath(r'\\server\dir\to\the\filestore\root')

A shapefile reader was added pointing to $(GIS_FILESHARE_ROOT)\sub\shp_folder\TheShapeFile.shp and this successfully reads the shapefile.

 

But, when I try do a similar thing but with a shapefile writer, I get an error.

Undefined macro 'GIS_FILESHARE_ROOT' dereferenced in file ... 

CaptureCan someone help me understand what's happening and how can I setup a similar dynamic root config like I did with the reader?

  • February 2, 2021

I got it working. For some reason, if I try to create the writer (or reader) initially setting the $(GIS_FILESHARE_FOOT) parameter, it falls over. I got around it by initially hardcoding the filepath just to create the reader/writer, and then edited the directory path with the $(GIS_FILESHARE_FOOT) parameter.


tomf
Contributor
Forum|alt.badge.img+14
  • Contributor
  • February 3, 2021

This is often the way these things need to be set in FME

  1. Create using full filepath, then after creation
  2. Amend filepath parameter to include user parameters or attributes.

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