How to deploy custom Python modules for use in the TIBCO Spotfire® clients.
Last updated:
5:14pm Jul 26, 2018
Back to main IronPython scripting page

Introduction

This article outlines the steps necessary to package Python custom modules in .py files, and deploy them on Spotfire Server for use in the Spotfire desktop client and Spotfire Web Player.

Procedure

Step 1: Create or gather the custom Python module file.

We create a custom Python module file in this example, but you could use an existing file.

  1. Create a new folder where you will place your custom Python module file.

  2. Launch a text editor and add the following function definition:

    def hello(string): return "Hello %s!" % (string,)
    
  3. Save the file as mymodule.py into the newly created folder.

Step 2: Create a package file (*.spk).

This step requires use of the TIBCO Spotfire SDK (TIBCO Spotfire Developer Software). This is a separate software product that can be obtained if you have a Spotfire Developer license. If this is your first time using the TIBCO Spotfire SDK, see the reference links below for installation instructions.

  1. Launch the SDK Package builder.

  2. Click the "Add..." button to add a new project.

  3. On the next window, leave selected the option "Add project: From folder:" > Click Browse, and select your Python files folder. This is the directory where you have kept all the files needed for this implementation.

  4. Un-check the button for "Source code folder."

  5. Click Next.

  6. Leave the default option for creating the module.xml file.

  7. Click Next.

  8. Select your Python module file to include within the package.

  9. Make sure that you are giving the Python module file (*.py file) a Public resource name that matches the same name as the file.

  10. Click Next.

  11. Change the intended client to "TIBCO Spotfire Any Client" to use the custom Python module on all TIBCO Spotfire clients, and provide other information such as the name and version number.

  12. Click Finish.

  13. Click the Validate and Save button.

  14. Right-click on the module and build an SPK file.

Step 3: Deploy the Package File onto the Spotfire Server

  1. Launch your browser, and navigate to the TIBCO Spotfire Server Administration Console. http://:/spotfire/administration/

  2. Click Add.

  3. Browse to select the package file that you created.

  4. Click OK to deploy the package onto the Deployment area.

  5. Click Validate.

  6. Click Save.

Step 4: Use your custom Python module in Spotfire Clients

  1. Start TIBCO Spotfire Professional/Analyst client, and connect to the Spotfire Server to install the package.

  2. Create an Iron Python script importing mymodule and calling the "hello" function as follows:

    from Spotfire.Dxp.Framework.ApplicationModel import NotificationService
    import sys
    sys.path.append(ModulesService.GetResourceDirectoryPath("mymodule.py"))
    from mymodule import hello
    	
    # Call Hello function
    x= hello("world");
    print x;
    # Notification service
    notify = Application.GetService[NotificationService]();
    notify.AddInformationNotification("Custom Python Module","Hello Function",str(x));

References

Attachments