<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html
  SYSTEM "about:legacy-compat">
<html xmlns:mml = "http://www.w3.org/1998/Math/MathML" lang = "en"><head><meta charset = "UTF-8"/><meta name = "copyright" content = "(C) Copyright 2020"/><meta name = "DC.rights.owner" content = "(C) Copyright 2020"/><meta name = "DC.type" content = "reference"/><meta name = "abstract" content = "This section shows the way a user can add a wrapper-tool for executable modules."/><meta name = "description" content = "This section shows the way a user can add a wrapper-tool for executable modules."/><meta name = "DC.format" content = "HTML5"/><meta name = "DC.identifier" content = "tso-r-cmd-driver-wrapper"/><meta name = "DC.language" content = "en"/><link rel = "stylesheet" type = "text/css" href = "../DSDocUI_XML34.css"/><title>Defining Wrappers for Executable Modules</title>
<script type = "text/javascript" src = "../DSDocUI_Highlight34.js">
  	/* */
  	</script></head><body onLoad = "highlightSearchTerms();" id = "tso-r-cmd-driver-wrapper">
<a name = "hj-top"> </a><table class = "table1" id = "table11"><tr><td><table class = "DocHeader"><tr><td class = "DocHeader1" colspan = "2"><h1>Defining Wrappers for Executable Modules</h1></td></tr><tr><td class = "DocHeader4" colspan = "2"/></tr><tr><td class = "DocHeader3" colspan = "2"><table class = "DocThemeIntro" id = "table12"><tr><td class = "Intro1Only"><p class = "header"><p class = "abstract">
<span class = "shortdesc">This section shows the way a user can add a wrapper-tool for executable modules.</span>

</p>
<p>This page discusses: </p><ul><li><a href = "#tso-r-cmd-driver-wrapper__tso-r-cmd-driver-wrapper-setup" id = "toc_rg" title = "">Setting-up Wrappers</a></li><li><a href = "#tso-r-cmd-driver-wrapper__tso-r-cmd-driver-wrapper-techniques" id = "toc_rg" title = "">Techniques and Best Practices</a></li></ul>
</p></td></tr></table></td></tr></table>




<div class = "body refbody">


<div class = "section" id = "tso-r-cmd-driver-wrapper__tso-r-cmd-driver-wrapper-setup"><h2 class = "title sectiontitle">Setting-up Wrappers</h2>

  <p>For <span class = "ph">Tosca</span> modules, the syntax is:</p>
  <pre class = "codeblock">
    <code class = "ph codeph">driver.Modules[ ToscaModules.&lt;module_name&gt; ].Wrapper = [ &lt;comma separated list of string arguments&gt; ]</code>
  </pre>
  <p>For the solver the syntax is:</p>
  <pre class = "codeblock">
    <code class = "ph codeph">driver.Solver.Wrapper = [ &lt;comma-separated list of string arguments&gt; ]</code>
  </pre>

  <p>Example of overriding the ToscaOpt-call:</p>
  <pre class = "codeblock">
    <code class = "ph codeph">DRIVER</code>
    <code class = "ph codeph">  driver.Modules[ ToscaModules.TOSCA_OPT ].Wrapper = [ r'E:\scratch\myScript.bat', '-arg1', 'value1', '-arg2', value2' ]</code>
    <code class = "ph codeph">END_</code>
  </pre>

  <p>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:</p>
  <pre class = "codeblock">
    <code class = "ph codeph">(INFO ) [tosca_python] E:\scratch\myScript.bat -arg1 value1 -arg2 value2 C:\N3V418\win_b64\code\bin\SMATsoToscaOpt --distribution --loglevel INFO</code>
  </pre>
  <p>Both command lines are concatenated with only a space as a separator.</p>
  <div class = "note"><span class = "run-in.note">Note:
			</span><span class = "notecontent">Specifying the path can be problematic under <span class = "ph">Windows</span> if using escape characters for the backslashes. The Python Driver uses the arguments "as is", without any special measure to keep the escape characters.</span></div>

</div>


<div class = "section" id = "tso-r-cmd-driver-wrapper__tso-r-cmd-driver-wrapper-techniques"><p><map name = "FPMap1"><area href = "#hj-top" title = "Back to Top" shape = "rect" coords = "416, 0, 435, 10"/></map><span class = "itemsprite"/></p><h2 class = "title sectiontitle">Techniques and Best Practices</h2>
  <p>It is recommended for <span class = "ph">Windows</span> path specifications to always use the Python raw string format with no escape characters:</p>
  <pre class = "codeblock">
    <code class = "ph codeph">r'E:\windows_path'</code>
  </pre>

  <p>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:</p>
  <pre class = "codeblock">
    <code class = "ph codeph">DRIVER</code>
    <code class = "ph codeph">  toolCmdLine = [ r'E:\scratch\scripts\myScript.bat', '-arg1', 'value1', '-arg2', 'value2' ]</code>
    <code class = "ph codeph">  driver.Modules[ ToscaModules.TOSCA_PREP ].Wrapper = toolCmdLine</code>
    <code class = "ph codeph">  driver.Modules[ ToscaModules.TOSCA_OPT  ].Wrapper = toolCmdLine</code>
    <code class = "ph codeph">END_</code>
  </pre>

  <p>Assigning the same tool to all the modules can be done using the <span class = "ph">Tosca</span> module-enumerable rather than listing each module separately:</p>
  <pre class = "codeblock">
    <code class = "ph codeph">DRIVER</code>
    <code class = "ph codeph">  toolCmdLine = [ r'E:\scratch\scripts\myScript.bat', '-arg1', 'value1', '-arg2', 'value2' ]</code>
    <code class = "ph codeph">  for module in ToscaModules.all():</code>
    <code class = "ph codeph">    driver.Modules[ module ].Wrapper = toolCmdLine</code>
    <code class = "ph codeph">END_</code>
  </pre>
  <div class = "note"><span class = "run-in.note">Note:
			</span><span class = "notecontent"> The solver will not be included in the above example.</span></div>


  </div>

</div>

</td></tr></table><script type = "text/javascript" src = "../DSDocUI_Bottom34.js">/* */</script></body>
</html>
