ParaView
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends
vtkPVPythonInterpretor Class Reference

Encapsulates a single instance of a python interpretor. More...

#include <vtkPVPythonInterpretor.h>

Inheritance diagram for vtkPVPythonInterpretor:
Inheritance graph
[legend]
Collaboration diagram for vtkPVPythonInterpretor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual const char * GetClassName ()
virtual int IsA (const char *type)
void PrintSelf (ostream &os, vtkIndent indent)
int PyMain (int argc, char **argv)
int InitializeSubInterpretor (int argc, char **argv)
void MakeCurrent ()
void RunSimpleString (const char *const script)
void RunSimpleFile (const char *const filename)
void ReleaseControl ()
void FlushMessages ()
void ClearMessages ()
void AddPythonPath (const char *)
void ExecuteInitFromGUI ()
virtual void SetCaptureStreams (bool)
virtual bool GetCaptureStreams ()

Static Public Member Functions

static vtkPVPythonInterpretorNew ()
static int IsTypeOf (const char *type)
static vtkPVPythonInterpretorSafeDownCast (vtkObject *o)

Protected Member Functions

 vtkPVPythonInterpretor ()
 ~vtkPVPythonInterpretor ()
virtual void InitializeInternal ()
void AddPythonPathInternal (const char *path)
virtual void SetExecutablePath (const char *)
void DumpError (const char *string)
void DumpOutput (const char *string)
vtkStdString GetInputLine ()
void DetachActiveSessionObserver ()

Protected Attributes

char * ExecutablePath
bool CaptureStreams
bool ActiveSessionObserverAttached

Friends

struct vtkPVPythonInterpretorWrapper

Detailed Description

Encapsulates a single instance of a python interpretor.

Encapsulates a python interpretor. It also initializes the interpretor with the paths to the paraview libraries and modules. This object can represent the main interpretor or any sub-interpretor.

Caveat:
Since this class uses a static variable to keep track of interpretor lock state, it is not safe to use vtkPVPythonInterpretor instances in different threads.

Definition at line 35 of file vtkPVPythonInterpretor.h.


Constructor & Destructor Documentation

vtkPVPythonInterpretor::vtkPVPythonInterpretor ( ) [protected]
vtkPVPythonInterpretor::~vtkPVPythonInterpretor ( ) [protected]

Member Function Documentation

static vtkPVPythonInterpretor* vtkPVPythonInterpretor::New ( ) [static]

Reimplemented from vtkObject.

Reimplemented in vtkPVPythonInteractiveInterpretor.

virtual const char* vtkPVPythonInterpretor::GetClassName ( ) [virtual]

Reimplemented from vtkObject.

Reimplemented in vtkPVPythonInteractiveInterpretor.

static int vtkPVPythonInterpretor::IsTypeOf ( const char *  type) [static]

Reimplemented from vtkObject.

Reimplemented in vtkPVPythonInteractiveInterpretor.

virtual int vtkPVPythonInterpretor::IsA ( const char *  type) [virtual]

Reimplemented from vtkObject.

Reimplemented in vtkPVPythonInteractiveInterpretor.

static vtkPVPythonInterpretor* vtkPVPythonInterpretor::SafeDownCast ( vtkObject o) [static]

Reimplemented from vtkObject.

Reimplemented in vtkPVPythonInteractiveInterpretor.

void vtkPVPythonInterpretor::PrintSelf ( ostream &  os,
vtkIndent  indent 
) [virtual]

Reimplemented from vtkObject.

Reimplemented in vtkPVPythonInteractiveInterpretor.

int vtkPVPythonInterpretor::PyMain ( int  argc,
char **  argv 
)

Initializes python and starts the interprestor's event loop i.e. call Py_Main().

int vtkPVPythonInterpretor::InitializeSubInterpretor ( int  argc,
char **  argv 
)

Initializes python and create a sub-interpretor context. Subinterpretors don't get argc/argv, however, argv[0] is used to set the executable path if not already set. The executable path is used to locate paraview python modules. This method calls ReleaseControl() at the end of the call, hence the newly created interpretor is not the active interpretor when the control returns. Use MakeCurrent() to make it active.

void vtkPVPythonInterpretor::MakeCurrent ( )

This method will make the sub-interpretor represented by this object the active one. A MakeCurrent() call must have a corresponding ReleaseControl() to avoid deadlocks.

void vtkPVPythonInterpretor::RunSimpleString ( const char *const  script)

Helper function that executes a script using PyRun_SimpleString() - handles some pesky details with DOS line endings. This method calls MakeCurrent() at the start and ReleaseControl() at the end, hence the interpretor will not be the active one when the control returns from this call.

void vtkPVPythonInterpretor::RunSimpleFile ( const char *const  filename)

Helper function that calls execfile().

void vtkPVPythonInterpretor::ReleaseControl ( )

Call in a subinterpretter to pause it and return control to the main interpretor. A MakeCurrent() call must have a corresponding ReleaseControl() to avoid deadlocks.

virtual void vtkPVPythonInterpretor::SetCaptureStreams ( bool  ) [virtual]

In some cases, the application may want to capture the output/error streams dumped by the python interpretor. When enabled, the streams are captured and output/error is collected which can be flushed by FlushMessages. vtkCommand::ErrorEvent is fired when data is received on stderr and vtkCommand::WarningEvent is fired when data is received on stdout. from the python interpretor. Event data for both the events is the text received. This flag can be changed only before the interpretor is initialized. Changing it afterwards has no effect.

virtual bool vtkPVPythonInterpretor::GetCaptureStreams ( ) [virtual]

In some cases, the application may want to capture the output/error streams dumped by the python interpretor. When enabled, the streams are captured and output/error is collected which can be flushed by FlushMessages. vtkCommand::ErrorEvent is fired when data is received on stderr and vtkCommand::WarningEvent is fired when data is received on stdout. from the python interpretor. Event data for both the events is the text received. This flag can be changed only before the interpretor is initialized. Changing it afterwards has no effect.

void vtkPVPythonInterpretor::FlushMessages ( )

Flush any errors received from the python interpretor to the vtkOutputWindow. Applicable only if CaptureStreams was true when the interpretor was initialized.

void vtkPVPythonInterpretor::ClearMessages ( )

Clears all received messages. Unlike FlushMessages, this call does not dump it on the vtkOutputWindow. Applicable only if CaptureStreams was true when the interpretor was initialized.

void vtkPVPythonInterpretor::AddPythonPath ( const char *  )

Add a directory to python path. Can be called only after InitializeSubInterpretor().

void vtkPVPythonInterpretor::ExecuteInitFromGUI ( )

Call this method to initialize the interpretor for ParaView GUI applications. This is typically called right after InitializeSubInterpretor().

virtual void vtkPVPythonInterpretor::InitializeInternal ( ) [protected, virtual]

Initialize the interpretor.

Reimplemented in vtkPVPythonInteractiveInterpretor.

void vtkPVPythonInterpretor::AddPythonPathInternal ( const char *  path) [protected]
virtual void vtkPVPythonInterpretor::SetExecutablePath ( const char *  ) [protected, virtual]
void vtkPVPythonInterpretor::DumpError ( const char *  string) [protected]
void vtkPVPythonInterpretor::DumpOutput ( const char *  string) [protected]
vtkStdString vtkPVPythonInterpretor::GetInputLine ( ) [protected]
void vtkPVPythonInterpretor::DetachActiveSessionObserver ( ) [protected]

Friends And Related Function Documentation

friend struct vtkPVPythonInterpretorWrapper [friend]

Definition at line 121 of file vtkPVPythonInterpretor.h.


Member Data Documentation

Definition at line 116 of file vtkPVPythonInterpretor.h.

Definition at line 117 of file vtkPVPythonInterpretor.h.

Declare that DetachActiveSessionObserver() should be called at close time. CAUTION: This must be set to true when paraview.servermanager.InitFromGUI() get called.

Definition at line 138 of file vtkPVPythonInterpretor.h.


The documentation for this class was generated from the following file: