span8
span4
span8
span4
Hi,
I want to trigger a workspace using a python script and with that,also want to set the reader dynamically as a parameter.I did look at a few posts previously on this subject like using the workspace runner or the Creator but wasn't sure if that would match my requirement.
My requirement is that - I have a set of workbenches that already have a Reader transformer added but I want to override those readers through Python script and provide dataset paths through python script.
It would be great help if I am advised whether I am trying this the wrong way and if I should be getting rid of the Readers from all my fmw files and take some other method that would allow me to provide the path in a way that the workbench could be triggered just by a python script and there would be no need to open the fmw files in FME Desktop
You can use Python scripted parameters for this,I do it quite often and it works really well.
Look at this post for some ideas:https://knowledge.亚搏在线safe.com/questions/34975/moving-workspaces-between-fme-installs-tips-and-tr.html
Thanks for the code and the ini-file,that helps a lot.
Two things:
Here's my attempt at cleaning up the code a bit and making it a bit more robust:
import osfrom ConfigParser import 亚搏在线SafeConfigParser # Built-in Python moduleini_file = FME_MacroValues['FME_MF_DIR'] + '/config/config.ini'if not os.path.isfile(ini_file): raise Exception('INI file not found: %s' % ini_file)# Initialize parserconfig = SafeConfigParser()# Read the ini fileconfig.read(ini_file)# Return option 'PER' under section 'DATA_INPUT'file_path = config.get('DATA_INPUT','wbo')# Check that the directory existsif not os.path.isdir(file_path): raise Exception('Directory not found: %s' % file_path)# Look inside directory for places.csv for file in os.listdir(file_path): # Case-insensitive filename comparison if file.lower().endswith("places.csv"): # We found the file,return filename return file_path+'\\'+file# Couldn't find the filereturn 'File places.csv not found.'
Hope it works for you.
Combining two FME workbenches,where one creates a parameter (new directory) for the other to use?2 Answers
Python Exception: No module named arcgisonlineCommon2 Answers
Rename file after translation3 Answers
How in reader can I know which feature types are selected by user ?0 Answers
Dynamic reader parameters0 Answers
© 2019 亚搏在线Safe Software Inc |Legal