6

errorI'm trying to run a second workspace using python command in "Shutdown Python Script" in the first workspace using the following command. But its giving me an error. Is there anything I need to do different? I am using FME 2012 SP 2

Thanks, Sam

So as suggested by Safe tech support, I created a batch file with the following code:

fme.exe c:\test2.fmw --SourceDataset_ARCGIS_LAYER C:\ScratchParcel\DevEnv.gdb\AddressPoint --DestDataset_SHAPE C:\temp

and added the following code in the shutdown python script window:

import os os.system("C:\\temp\\test.bat")

When I run it, although it says transaction was successful, I don't get any results i.e., the output shapefile is not created.

10
  • Is there a test2.log in the same folder as test2.fmw? If that's being created when you run the batch file then it's running properly and the workspace itself isn't working correctly.
    – blah238
    Commented Jun 20, 2012 at 20:41
  • There is no log file being created. So does this mean there is something wrong with the code?
    – Sam
    Commented Jun 20, 2012 at 20:48
  • Does it work if you run the batch file directly? Run it from a command window or add a pause statement so it doesn't disappear before you can see what it says.
    – blah238
    Commented Jun 20, 2012 at 22:32
  • I added pause statement to the batch file and there was a tanslation failed message. I uploaded the screen shot of it but it disappeared. Is there any other way to upload the image?
    – Sam
    Commented Jun 21, 2012 at 13:05
  • Assuming you can run the test2.fmw workspace in workbench, try deleting the --Source/DestDataset params and simply running 'fme.exe c:\test2.fmw'.
    – Raven
    Commented Jun 21, 2012 at 16:32

2 Answers 2

5

Your Python doesn't look syntactically valid. Try

import os
os.system("fme.exe C:\\temp\\test2.fmw --SourceDataset_ARCGIS_LAYER C:\\ScratchParcel\\DevEnv.gdb\\AddressPoint --DestDataset_SHAPE C:\\temp")

I've added the parens and quotes around the string you are passing to os.system, and escaped the backslashes.

Update: In addition, the fme.exe in your path is different than the fme.exe being run by Workbench. Explicitly specify the path to the fme.exe you want to run:

os.system("c:\\pathToFme\\fme.exe test2.fmw")

or, perhaps in this more future proof manner

os.system(os.path.join(os.environ['FME_HOME'], "fme.exe") + " test2.fmw")

which says "run using the fme.exe that we are currently running".

4
  • Raven, I am still getting error with the python execution.
    – Sam
    Commented Jun 20, 2012 at 17:39
  • What error do you get? Is it a Python error or an FME error?
    – Raven
    Commented Jun 20, 2012 at 19:25
  • The logfile says its successful but I dont see any results. "FME_END_PYTHON: evaluating python script from string... FME_END_PYTHON: python script execution complete."
    – Sam
    Commented Jun 20, 2012 at 20:10
  • There should be a log file left over from the fme.exe execution invoked by your end Python. You can override the log location in the test2.fmw sub-workspace if you are having trouble finding it. (Can be done via command line too, but I can't remember how offhand.)
    – Raven
    Commented Jun 20, 2012 at 22:52
1

FME start up and shutdown scripts (FME, Python and Oracle)

only screenshots of the startup/shutdown process so you will have to create your own.

enter image description here

The whole process is a multi-stage system, requiring the use of FME startup and shutdown scripts.

http://fmepedia.safe.com/articles/Samples_and_Demos/Example-Workflow-using-FME-Python-and-Oracle

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.