FME_BEGIN_PYTHON

The FME_BEGIN_PYTHON directive specifies a Python script file to execute just prior to the start of translation. The script is executed after the mapping file has been completely parsed, and after the log file has been opened, but before any of the readers or writers have begun to do their processing.

Note: FME will abort the translation if the execution of FME_BEGIN_PYTHON scripts fails. If, for some reason, this behavior is undesirable and you want to continue a translation even if the execution fails, you can use Python's exception handling to trap errors, allowing FME to continue with the translation.

The syntax is:

FME_BEGIN_PYTHON <python script>

where the <python script> is any valid Python script file to execute.

The script may access the following variables in the 'fme' Python module:

Variable

Contents

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.mappingFileId

The value of the MAPPING_FILE_ID directive specified in the mapping file

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.licensing (FME 2013+)

The edition information and FME license type.

Note: To import the 'fme' Python module, execute the statement import fme.