Defining Wrappers for Executable Modules

This section shows the way a user can add a wrapper-tool for executable modules.

Setting-up Wrappers

For Tosca modules the syntax is:

    driver.Modules[ ToscaModules.<module_name> ].Wrapper = [ <comma separated list of string arguments> ]
  

For the solver the syntax is:

    driver.Solver.Wrapper = [ <comma-separated list of string arguments> ]
  

Example of overriding the ToscaOpt-call:

    DRIVER
      driver.Modules[ ToscaModules.TOSCA_OPT ].Wrapper = [ r'E:\scratch\myScript.bat', '-arg1', 'value1', '-arg2', value2' ]
    END_
  

The Python driver will execute the given command line by appending the command line of the corresponding module. Here is how the call for the last example would look like:

    (INFO ) [tosca_python] E:\scratch\myScript.bat -arg1 value1 -arg2 value2 C:\N3V418\win_b64\code\bin\SMATsoToscaOpt --distribution --loglevel INFO
  

Both command lines are concatenated with only a space as a separator.

Note: Specifying the path can be problematic under Windows if using escape characters for the backslashes. The Python Driver uses the arguments "as is", without any special measure to keep the escape characters.

Techniques and Best Practices

It is recommended for windows path specifications to always use the Python raw string format with no escape characters:

    r'E:\windows_path'
  

If a command line argument list is about to be used more than once it is advisable to put the arguments into a separate variable and reuse it for the assignments:

    DRIVER
      toolCmdLine = [ r'E:\scratch\scripts\myScript.bat', '-arg1', 'value1', '-arg2', 'value2' ]
      driver.Modules[ ToscaModules.TOSCA_PREP ].Wrapper = toolCmdLine
      driver.Modules[ ToscaModules.TOSCA_OPT  ].Wrapper = toolCmdLine
    END_
  

Assigning the same tool to all the modules can be done using the Tosca module-enumerable rather than listing each module separately:

    DRIVER
      toolCmdLine = [ r'E:\scratch\scripts\myScript.bat', '-arg1', 'value1', '-arg2', 'value2' ]
      for module in ToscaModules.all():
        driver.Modules[ module ].Wrapper = toolCmdLine
    END_
  

Note: The solver will not be included in the above example.