fmeobjects.FMEWorkspaceRunner

Inheritance diagram of fmeobjects.FMEWorkspaceRunner

FMEWorkspaceRunner.getParamDefaultValue(...)

This method retrieves the default value of the parameter specified by paramName.

FMEWorkspaceRunner.getParamLabel(workspace, ...)

This method retrieves the label str that describes the parameter specified by paramName.

FMEWorkspaceRunner.getParamOptional(...)

This method determines if the specified parameter name on the workspace is an optional parameter.

FMEWorkspaceRunner.getParamType(workspace, ...)

This method retrieves the parameter type of the specified parameter name.

FMEWorkspaceRunner.getParamValues(workspace, ...)

This method retrieves the possible parameter values of the specified parameter name.

FMEWorkspaceRunner.getPublishedParamNames(...)

This method retrieves all the published parameter names on the specified workspace.

FMEWorkspaceRunner.promptRun(workspace, ...)

Executes the workspace file specified.

FMEWorkspaceRunner.run(workspace, parentHandle)

Executes the workspace file specified.

FMEWorkspaceRunner.runWithParameters(...)

Executes the workspace file specified using the parameter values.

FMEWorkspaceRunner.runWithParametersAndDirectives(...)

Executes the workspace file specified using the parameter values and FME directives.

class FMEWorkspaceRunner

FME Workspace Runner Class

init()

Create an instance of a workspace runner that can be used to run FME workspaces and retrieve information about FME workspaces.

__init__(*args, **kwargs)
getParamDefaultValue(workspace, paramName)

This method retrieves the default value of the parameter specified by paramName. If the the parameter does not have a default value, an empty str is returned.

Parameters:
  • workspace (str) – The path to the workspace containing parameter name.

  • paramName (str) – The parameter name of the default value to retrieve.

Return type:

str

Returns:

The parameter default value.

Raises:

FMEException – An exception is raised if the parameter is not found on the workspace.

getParamLabel(workspace, paramName)

This method retrieves the label str that describes the parameter specified by paramName.

Parameters:
  • workspace (str) – The path to the workspace containing parameter name.

  • paramName (str) – The parameter name of the label to retrieve.

Return type:

str or None

Returns:

The parameter label str.

Raises:

FMEException – An exception is raised if the parameter is not found on the workspace.

getParamOptional(workspace, paramName)

This method determines if the specified parameter name on the workspace is an optional parameter.

Parameters:
  • workspace (str) – The path to the workspace containing parameter name.

  • paramName (str) – The parameter name to determine if optional.

Return type:

bool or None

Returns:

True if the parameter is optional, False otherwise.

Raises:

FMEException – An exception is raised if the parameter is not found on the workspace.

getParamType(workspace, paramName)

This method retrieves the parameter type of the specified parameter name.

A full description of each parameter type can be found here:

http://docs.safe.com/fme/html/FME_GuiType/

Parameters:
  • workspace (str) – The path to the workspace containing parameter name.

  • paramName (str) – The parameter name of the type to retrieve.

Return type:

str or None

Returns:

The parameter type.

Raises:

FMEException – An exception is raised if the parameter is not found on the workspace.

getParamValues(workspace, paramName)

This method retrieves the possible parameter values of the specified parameter name. Parameter value availability is dependent on the parameter type of the parameter. Here are some examples of the format the parameter values are returned as, given a certain parameter type:

  • INTEGER:
    • paramValues is empty because possible values is the set of integers.

  • CHOICE: < value >[%< value2 >]*
    • Each possible value is separated by a ‘%’.

  • LOOKUP_CHOICE: < displayValue >[,< returnValue >][%< displayValue >[,< returnValue >]]*
    • The display values and return values are separated by a ‘,’, with the return values being optional. Each possible “pair” are separated by a ‘%’.

  • FILENAME: < filterDes >|< filter >[|< filterDes2 >|< filter2 >]*
    • The filter descriptions and the filter extension types are separated by a ‘|’.

A full description of the parameter value format for each parameter type can be found here:

http://docs.safe.com/fme/html/FME_GuiType/

Parameters:
  • workspace (str) – The path to the workspace containing parameter name.

  • paramName (str) – The parameter name of the values to retrieve.

Return type:

str or None

Returns:

The possible parameter values.

Raises:

FMEException – An exception is raised if the parameter is not found on the workspace.

getPublishedParamNames(workspace)

This method retrieves all the published parameter names on the specified workspace.

Parameters:

workspace (str) – The path to the workspace to retrieve parameter names.

Return type:

tuple[str] or None

Returns:

The published parameter names.

Raises:

FMEException – An exception is raised if the published parameter names could not be retrieved on the workspace specified.

promptRun(workspace, parentHandle)

Executes the workspace file specified. This method will always prompt for any published parameters before running the workspace.

This method will run mapping files in addition to workspaces. However, workspaces are preferred over mapping files due to the configuration ease workspaces provide.

Parameters:
  • workspace (str) – The path to the workspace to run.

  • parentHandle (int) – (Optional) The window handle that the FME prompt dialogs will be bound to.

Return type:

None

Raises:

FMEException – An exception is raised if the running of the workspace failed.

run(workspace, parentHandle)

Executes the workspace file specified. The first time this method is called on a workspace, any published parameters will be prompted for before the workspace is run. Subsequent calls to this method with the same workspace will not prompt for published parameters. The published parameters specified during the first call to this method will be used in the subsequent calls.

This method will run mapping files in addition to workspaces. However, workspaces are preferred over mapping files due to the configuration ease workspaces provide.

Parameters:
  • workspace (str) – The path to the workspace to run.

  • parentHandle (int) – (Optional) The window handle that the FME prompt dialogs will be bound to.

Return type:

None

Raises:

FMEException – An exception is raised if the running of the workspace failed.

runWithParameters(workspace, parameters)

Executes the workspace file specified using the parameter values. The parameter values are to be specified as name/value pairs. For example, for the pair SHAPE_IN_DISSOLVE_HOLES_SHAPE/no:

>>> runner.runWithParameters('workspace.fmw', {'SHAPE_IN_DISSOLVE_HOLES_SHAPE', 'no'})
Parameters:
  • workspace (str) – The path to the workspace to run.

  • parameters (dict[parameters]) – Parameter name and values dictionary.

Return type:

None

Raises:

FMEException – An exception is raised if the running of the workspace failed.

runWithParametersAndDirectives(workspace, parameters, directives)

Executes the workspace file specified using the parameter values and FME directives. Both the parameter values and FME directives are to be specified as name/value pairs. For example, for the parameter pair SHAPE_IN_DISSOLVE_HOLES_SHAPE/no and FME directive pair LOG_FILENAME/out.log:

>>> IFMEStringArray* parameters = fmeSession->createStringArray();
>>> parameters->append("SHAPE_IN_DISSOLVE_HOLES_SHAPE");
>>> parameters->append("no");
>>> IFMEStringArray* directives = fmeSession->createStringArray();
>>> parameters->append("LOG_FILENAME");
>>> parameters->append("out.log");
>>> runner->runWithParametersAndDirectives(*workspace, *parameters, *directives);
Parameters:
  • workspace (str) – The path to the workspace to run.

  • parameters (dict[parameters]) – Parameter name and values dictionary.

  • directives (dict[directives]) – Directive name and values dictionary.

Return type:

None

Raises:

FMEException – An exception is raised if the workspace did not run successfully.