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.
-
Create a new folder where you will place your custom Python module file.
-
Launch a text editor and add the following function definition:
def hello(string): return "Hello %s!" % (string,)
-
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.
-
Launch the SDK Package builder.
-
Click the "Add..." button to add a new project.
-
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.
-
Un-check the button for "Source code folder."
- Click Next.
-
Leave the default option for creating the module.xml file.
-
Click Next.
-
Select your Python module file to include within the package.
-
Make sure that you are giving the Python module file (*.py file) a Public resource name that matches the same name as the file.
-
Click Next.
-
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.
-
Click Finish.
-
Click the Validate and Save button.
-
Right-click on the module and build an SPK file.
Step 3: Deploy the Package File onto the Spotfire Server
-
Launch your browser, and navigate to the TIBCO Spotfire Server Administration Console. http://<host>:<port>/spotfire
-
Click on "Deployments and Packages"
-
Select a Deployment Area and click Add.
-
Browse to select the package file that you created.
-
Click upload to add the package to the Deployment area.
-
Click Validate (if present)
Step 4: Use your custom Python module in Spotfire Clients
-
Start TIBCO Spotfire Professional/Analyst client, and connect to the Spotfire Server to install the package.
-
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));
Results
References
-
Download the file How to Deploy Python Modules for Use on Spoftfire Clients from Resources how_to_deploy_python_modules_for_use.pdf
Recommended Comments
There are no comments to display.