FME_END_PYTHON
The FME_END_PYTHON directive specifies a Python script file to execute just after translation has completed, either successfully or prematurely due to an error being encountered.
If the translation ended due to an error, the script is executed after all cleanup is done, all reader and writers are shut down, and the log file has been closed. If the translation was successful, the script is executed after all the readers and writers have finished their work, and the log file has been closed.
The script has access to any global Python variables set in the FME_BEGIN_PYTHON script.
The script has access to a number of variables and functions in the 'fme' Python module that contain statistics and other information about the translation.
Note To import the 'fme' Python module, execute the statement import fme.
The script may access the following functions variables. Note that if the translation failed, only the fme.status and fme.failureMessage are guaranteed to contain valid values.
Global Function |
Description |
fme.resolveFMEMacros(value) |
Resolve all FME macros in the input string and return the resolved string. FME macros are defined as all character sequences that match the pattern $(<alphanumeric characters including '_'>). If a matching pattern does not resolve to an FME macro, the matching pattern will remain untouched. |
fme.getAbsolutePath(fileName) |
Given an input file name or FME macro of a file name, this method will return an absolute path of the file name. Unless the resolved input file name is an absolute path itself, the absolute path will be determined with the assumption that the input is relative to the executing Workspace. |
Global Variable |
Contents |
fme.cpuTime |
The total CPU time in seconds from just before the FME_BEGIN_PYTHON script was called until just before the FME_END_PYTHON script was called. |
fme.cpuUserTime |
The amount of user CPU time in seconds from just before the FME_BEGIN_PYTHON script was called until just before the FME_END_PYTHON script was called. |
fme.cpuSysTime |
The amount of system CPU time in seconds from just before the FME_BEGIN_PYTHON script was called until just before the FME_END_PYTHON script was called. |
fme.elapsedRunTime |
The actual elapsed (wall clock) time in seconds from just before the FME_BEGIN_PYTHON script was called until just before the FME_END_PYTHON script was called. |
fme.failureMessage |
The failure message if the translation failed, blank if the translation succeeded. |
fme.featuresRead |
A Python dictionary, indexed by feature type, which holds the number of features read for that feature type. |
fme.featuresWritten |
A Python dictionary, indexed by feature type, which holds the number of features written for that feature type. |
fme.licensing (FME 2013+) | The edition information and FME license type. |
fme.logFileName |
The name of the log file used for this translation. Note Writing custom (user-defined) messages to the log file varies depending on whether it is during the start-up or shutdown phase. In a start-up script (because FME already has the log file open, and it is dangerous to open it more than once) you should use fmeobjects.FMELogFile().
|
fme.macroValues |
A python dictionary, indexed by macro name, which holds the value of each macro known within the workspace or mapping file at the end of parsing. |
fme.mappingFileId |
The value of MAPPING_FILE_ID keyword if specified in the mapping file |
fme.memoryUsage (FME 2013+) | The amount of memory (in kilobytes) in use at the end of the translation. |
fme.peakMemoryUsage (FME 2013+) |
The maximum amount of memory that was used at any point during the translation. |
fme.processID (FME 2013+) |
The ID of the current process. |
fme.numFeaturesLogged |
This variable records the total number of requests for features to be logged. This can be helpful to detect features that a writer may have rejected. Note that to avoid accumulating hundreds of features in the log, FME by default suppresses all log attempts after the first 20. Therefore, the actual number of features logged may be fewer than the number requested. |
fme.status |
False if the translation failed and True if it was successful |
fme.totalFeaturesRead |
The total number of features read |
fme.totalFeaturesWritten |
The total number of features written |