Home
Categories
Dictionary
Glossary
Download
Project Details
Changes Log
What Links Here
FAQ
License

Python configuration properties



The global framework properties have several properties which are used for Python modules:
  • The path of the Python executable to execute Python scripts
  • The default Python version to execute Python scripts
  • The behavior of Python scripts when encountering Deprecation or Future warnings
  • The default port size for commmunicating with Python scripts
  • Show the python command-line when Python processes are started
  • Set the default values for the waitAtStart and waitAtInit properties for Python modules
  • Set if python warnings should be shown on the console
  • Set if the echo and print commands in Python must be shown
  • Set if the python module name must me stripped from the logs
  • Set if enumerations should be sent by default with their state names rather than an int

Python executable path

By default the framework will look for a Python 2.x executable among the applications installed on the System.

There are two ways to define the Python runtime which will call Python scripts:
  • Through the pythonDefaultRuntime property with the python2 or python3 values: it will look for a Python2 or Python3 installed version of Python
  • Through the pythonRuntime or pythonRuntimeEnv properties: it will set the default runtime to use for all Python scripts
Note that:
  • You must use the correct version of the Python scripts depending on the version of Python you intend to use
  • You can override the Python runtime for a Python module, which allows you to use different Python runtimes for different modules
See generating a Python library for more information.

Python default runtime

The pythonDefaultRuntime property can be set to define which Python version should be executed if the pythonRuntime property is not set. The version will be assumed to be Python3.x if the value (regardless of the case) is "python3", and Python2.x for all other values[1]
If the pythonRuntime property or pythonRuntimeEnv property is set, the defaultPythonRuntime property will not be used
.

For example:
      <files>
      ...
         <property key="pythonDefaultRuntime" value="python3" />
      </files>

Python runtime path

The pythonRuntime property can be set to force the path of the Python executable used to execute Python scripts. Note that if the path is a symbolic link linking to a real Python executable, the framework will follow this link.

For example:
      <files>
      ...
         <property key="pythonRuntime" value="C:/Program Files (x86)/Python24/python.exe" />
      </files>

Alternate way to define the Python runtime path

An alternate way to define the Python executable path is through the pythonRuntime element. For example:
      <files>
      ...
         <property key="pythonRuntime" value="C:/Program Files (x86)/Python24/python.exe" />
      </files>
is equivalent to:
      <files>
      ...
         <pythonRuntime path="C:/Program Files (x86)/Python24/python.exe" />
      </files>
This way of setting the path allows to define that Python is executed inside Anaconda. For example:
      <files>
      ...
         <pythonRuntime path="L:/WRK/Anaconda3/python.exe" anaconda="true" />
      </files>

Python runtime env

The pythonRuntimeEnv property can be set to define the environment variable used to call Python executable, used to execute Python scripts. It is often useful in Unix systems.

For example:
      <files>
      ...
         <property key="pythonRuntimeEnv" value="python38" />
      </files>

Default Python version

The pythonDefaultRuntime property can be set to define which Python version should be executed if the pythonRuntime property is not set. The version will be assumed to be Python3.x if the value (regardless of the case) is "python3", and Python2.x for all other values[1]
If the pythonRuntime property or pythonRuntimeEnv property is set, the defaultPythonRuntime property will not be used
.

Show the Python Command-line

The showPythonCommandLine property is a boolean property which allows to show the command-line started by the Python process on the Logger output.

For example:
      <files>
      ...
         <property key="showPythonCommandLine" value="true" />
      </files>

Ignore python warnings in the console

The ignorePythonWarnings property is a boolean property specifying if warning messages should be ignored rather than be shown on the console. The default is false.

For example:
      <files>
      ...
         <property key="ignorePythonWarnings" value="true"/>
      </files>

Python default port size

The pythonDefaultPortSize property can be set to specify the default input and output port size for the communication between Java and Python, when using Python socket modules.

Python Deprecation, Future warnings, and User Warnings behavior

The ignorePythonWarnings property can be set to ignore warnings emitted by Python scripts.

This will hide the following Python warnings:
  • Deprecation warnings
  • Future warnings
  • User warnings
For example:
      <files>
      ...
         <property key="ignorePythonWarnings" value="true" />
      </files>

PyWaitAtStart property


The pyWaitAtStart property specifies the default value for the waitAtStart property for the Python modules. The default value if nothing is specified is 200 ms.



For example:
      <files>
      ...
         <property key="pyWaitAtStart" value="500ms" />
      </files>

PyWaitAtInit property


The pyWaitAtInit property specifies the default value for the waitAtInit property for the Python modules. The default value if nothing is specified is 200 ms.

This is only used for Python socket modules.


For example:
      <files>
      ...
         <property key="pyWaitAtInit" value="500ms" />
      </files>

Enumerations as String

By default, enumeration values for the JSON content sent to the Python module are sent with the state value (an int).

The pythonEnumAsString property specifies that the state names should be sent instead. Note that this can also be condifured with the framework property of the same name.

Python runtime properties

These properties are set as attributes of the pythonRuntime element.

Don't show the echo and print commands in the console

The echoOff property is a boolean property specifying if the echo and print commands must be siletnly ignored and not shown in the console. The default is false.

For example:
      <files>
      ...
         <pythonRuntime path="C:/Program Files (x86)/Python24/python.exe" echoOff="true"/>
      </files>

Strip the python module name from the logs

The stripModuleFromLogs property is a boolean property specifying if the python module name must be stripped from the logs. The default is false.

For example:
      <files>
      ...
         <pythonRuntime path="C:/Program Files (x86)/Python24/python.exe" stripModuleFromLogs="true"/>
      </files>

Notes

  1. ^ [1] [2] If the pythonRuntime property or pythonRuntimeEnv property is set, the defaultPythonRuntime property will not be used

See also


Categories: config

Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence