Setting Up Your Environment for Python Developers

You can use Python to write a Wiretap client that can run immediately, without compiling.

If you need to become familiar with Python, visit the web site: http://www.python.org/

Your Wiretap client will be a Python module (a .py file). To run your module, you will need a dynamic library that provides Python bindings to the C++ version of the Wiretap Client API. Check the next section to see if a Python library is available for your platform. If there is, you can proceed to Setting Up the Python Environment.

Availability of Python API

There is a pre-compiled version of the Wiretap Client API that was compiled with Python 2.7. It is only available for these platforms:

Location of the Python Libraries

You will find the appropriate version of the Wiretap dynamic library for Python in your wiretap_install_dir. The following table indicates the names of the library files and the path to these files.

There is no library file for Windows. You need to compile a .dll as described in Setting Up the Python Environment.

OS Platform (Bits) Compiler/ Version Path to Library Files Wiretap Library File for Python
Linux RHEL 6 x86-64(64) GCC 4.4.6

wiretap_install_dir/lib/opt/LINUX/

x86_64/RHEL6/GCC_4_4_6/Python2.7

libwiretapPythonClientAPI.so

Mac OSX Intel(64) GCC 5.1

wiretap_install_dir/lib/opt/MACOSX/

fat/10_9_5/GCC_5_1/Python*

libwiretapPythonClientAPI.dylib

Note: On the Mac, three versions of the Wiretap library file are available. Python2.7, Python2.7.system, and Python2.6.system. If you plan on building something that includes the Creative Finishing Python hooks, you must use the Python2.7 distribution. If not, use the .system distribution that matches you Mac OS X Python distribution.

Setting Up the Python Environment

To use a version of Python other than the recommended version 2.7, or if your OS does not come with Python (Windows), set up your development environment using the following steps:

  1. Ensure a dynamic library for boost (C++ extensions) is installed on your system:
    • If you are working on Linux or Mac OS X, a boost dynamic library might have already been installed on your system.
    • If you do not have a boost library, you will need to build one from the sources available at:

    For more details, see http://www.boost.org.

  2. Ensure Python is installed on your system. Preferably, it should be version 2.7, because the dynamic library (that defines Python bindings for Wiretap) works correctly with it. Python 2.6 might work, Python 3.0 will not.

    If you need to get Python, go to the Python web site:

    http://www.python.org/

  3. If you want to use a version of Python other than the pre-compiled version, you must regenerate the Wiretap dynamic library for Python as follows:
    • Compile wiretapPythonClientAPI.C (in the samples directory of the Wiretap Client SDK).
    • Specify the boost library (from Step 1) in your compile command.
    • The resulting library must be named libwiretapPythonClientAPI (with a platform-appropriate extension: .so for Linux, .dylib for Mac OS X, .dll for Windows) and must be installed as explained in the rest of this procedure.
  4. Check Location of Python Libraries to determine the location of the appropriate version of the Wiretap dynamic library for Python.
  5. Ensure that the library files (for boost and libwiretapPythonClientAPI) are found at runtime in either of these standard ways:
    • Add the paths of the library files to your system path

      or

    • Install the library files in Python’s library directory (which is platform-dependent):

      - Linux 32-bit: /usr/lib/python2.7/lib-dynload

      - Linux 64-bit: /usr/lib64/python2.7/lib-dynload

      - Mac OS X: /usr/lib/python2.7/lib-dynload

      - Windows: C:\Python27\DLLs

Running Python Modules

Once you have ensured that Python is installed and can find the required libraries, you can run the sample Python modules (.py files) included in the Wiretap Client SDK.

where,

Accessing Documentation for the Python API

The Wiretap Client SDK does not include documentation specifically for the Python version of the API. However, you can view the list of classes and their member functions in the API by using the Python commands dir and help as shown below.

To get help for the Python API:

  1. Start Python, or open a shell or command prompt and enter:

    python

    The python prompt (>>>) appears.

  2. To import the Wiretap API (with an alias), enter:

    import libwiretapPythonClientAPI as wiretap

  3. To view a list of the classes in the API, enter:

    dir(wiretap)

  4. To view the members of a particular class in the API, enter:

    help (wiretap.WireTapServerHandle)

    For detailed information about the member functions of a class, you must use the Wiretap C++ API reference documentation.

To get more information about the methods of a class:

Differences between the Python API and the C++ API

The Python API is designed to resemble the C++ API as much as possible. However, there are a few differences between the C++ and Python versions of the API. Unlike C++, Python does not support pointers and references. Python uses objects in situations where C++ would use pointers and references.

In the Wiretap Client API, some C++ accessor methods have output parameters that pass references to integers. The equivalent Python methods pass an instance of WireTapInt, which is used to represent the int base type.

Affected Classes and Methods

These are the Python method declarations that differ from the equivalent C++ declarations:

class WireTapServerHandle
  bool getVersion( WireTapInt &major, WireTapInt &minor ) const
  bool getProtocolVersion( WireTapInt &major, WireTapInt &minor ) const
 
class WireTapNodeHandle
  bool getNumAvailableMetaDataStreams( WireTapInt &numStreams ) const
  bool getNumChildren( WireTapInt &numChildren ) const
  bool getNumFrames( WireTapInt &numFrames ) const
  bool getNodeType( WireTapInt &type ) const
  bool linkToFrames( python::list pathList )
 
class WireTapServerList        
  bool getNumNodes( WireTapInt &numberOfNodes )