Hi Richard,
write a shutdown script with the following Python code:
-----
import fmeobjects import pprint pp = pprint.PrettyPrinter(indent=4) pp.pprint(FME_MacroValues)
-----
It will output all the possible dictionary keys available in FME_MacroValues to the log file. I suspect you will not find "FME_Executable" in there, but you might find another key that does about the same thing.
Also have a look
here for more info.
David
Hi again,
one more thing: if you have copied this code from elsewhere, please note that it does not look complete at all. There are references to undefined objects (the class "myWorkbench" in particular) and I doubt you will get it to work unless you have a lot more code than what you posted.
It also seems that it references some workbench-specific user parameters (have you defined those?), such as "FME_Executable", "Workbench_To_Run" and "FMW".
What are you trying to accomplish? There might be a better way...
David
Thank you David!
That was a very useful code! Although it helped me get through other problems there is no key to get the FME executable. I must indicate I am running the executables logged onto a Citrix Server, if that helps.
Any comment, will be much appreciated.
Thanks,
Richard.
Hi Richard,
good to hear you're on track. It is very possible that "FME_Executable" was defined as a user parameter (either private or published) in the workspace where you got your code.
If you have the original workspace available, I recommend you have a look there to see how it is defined. If not, you could just create a user parameter called "FME_Executable" and set it to the desired value, e.g. "C:/Program Files/FME/fme.exe"
David
Hi David:
Thank you so much, I found the solution. And yes, I created those values and the final script looks like this (at least works, although not very elegant).
I was incorporating this as part of the Python Shutdown script to execute upon succesful data load. The script calls another script, defined as "Workbench_To_Run". It does work now, and I am reviewing the results of the second script's run.
Code below:
import pyfme import os import subprocess logger = pyfme.FMELogfile() fmeExecutable = os.path.normpath(FME_MacroValuesE'FME_HOME'])+'\\FME.exe' workBench = os.path.normpath(FME_MacroValuesF'Workbench_To_Run']) # initiate materialized view refresh if changes to either source if FME_TotalFeaturesWritten > 0: logger.log('Updates detected, executing materialized view refresh script - ' + workBench) args = ofmeExecutable, workBench] p = subprocess.Popen(args)
Thanks again!
Richard,