extools.env

A number of helpers are available here for the Extender Python environment. For example: extools.env.execution_context() can detect whether a script is running through PS or VI, and whether you can show messages.

Aso included is the extools.env.StreamConductor, which allows you to temporarily redirect and capture the standard input and output streams used globally. Useful for getting code to run that expects these streams to be connected.

Tools for the Extender Python environment.

extools.env.EXEC_PS = 1

Process Sceduler Execution Context

extools.env.EXEC_VI = 0

Extender Execution Context

extools.env.execution_context()[source]

Are we running through PS or VI?

Returns:EXEC_PS if PS else EXEC_VI
class extools.env.stream_conductor.StreamConductor(stdout=None, stderr=None, stdin=None)[source]

Bases: object

The StreamConductor manages standard I/O operations for Extender.

The Extender environment isn’t connected to stdout, stderr, or stdin. To allow applications that assume they’ll be present to work, StreamConductor patches them to string buffers that can be read from or written to.

Parameters:
  • stdout (file-like object) – file-like object for stdout.
  • stderr (file-like object) – file-like object for stderr.
  • stdin (file-like object) – file-like object for stdin.
patch_streams()[source]

Patch stdout, stderr, and stdin.

patched_streams()[source]

Temporarily patch streams, making sure they are restored.

Context manager for working with patched streams temporarily. After the block exits, the streams will be restored to their original state.

conductor = StreamConductor()
with conductor.patched_streams():
    print("Hello")

print(conductor.stdout.getValue()) # prints "Hello"
unpatch_streams()[source]

Restore streams to their original state.