Below are some frequently asked questions when using Python scripting in Pulsonix using the Scripting API. Further information about the Python scripting interface can be found here.

This page is not related to Legacy Scripting.

What is Python?

Python is a general purpose scripting language with a simple syntax and rich tooling and libraries. The python.exe interpreter reads Python scripts and runs their code line by line.

What is the Pulsonix Python client?

The Scripting Dashboard can generate a set of Python source files (the Pulsonix Python client) which can be used to interact with the Scripting API.

What is the Python launcher and the PATH?

The Python launcher is a separate application that lets you manage multiple Python versions without conflicts on the PATH. The launcher itself is automatically added to the PATH with the name py.exe, and can be used to invoke Python scripts using the latest installed Python version or with a specific version.

PATH is an environment variable which describes to Windows where programs that should be available in command prompts are located. Adding the folder containing python.exe to the PATH makes it possible to call Python scripts from any directory in a command prompt by typing python <script path>. By using the PATH, the command prompt can locate python.exe and pass it the script.

Can I use Python scripts designed for Legacy Scripting with the Scripting API?

No, but most scripts will require only slight modifications to work with the API.

A full guide on upgrading Legacy scripts is available.

How do I create Python scripts?

Python scripts are plaintext files which can be created in the Windows File Explorer by creating a new file and giving it the .py extension.

How do I edit Python scripts?

Python scripts are plaintext files which can be edited with simple text editor such as Windows Notepad or Notepad++.

For a better development experience with the Pulsonix Python client, including auto-complete, syntax checking and debugging support, you can use third party Integrated Development Environments (IDEs) such as IDLE, PyCharm or Visual Studio Code with the Microsoft Python extension.

How do I run Python scripts?

See Running Python Scripts for information on how to run Python scripts.

Can I run Python scripts from a graphical interface?

Yes. Several methods of doing so are explained here.

Can I run Python scripts without the Pulsonix interface open?

The API is still available and Python scripts still work when Pulsonix is running in hidden mode.

Can I run Python scripts without Pulsonix running?

Yes, Pulsonix needs to be running to provide the Scripting API. Scripts using the Pulsonix Python client will run but raise errors if they can not communicate with the API.

Can the client be used on different versions of Pulsonix?

Yes, but not always. Updates to Pulsonix may remove, add or change API functionality, which would require re-installation of the client package via the Scripting Dashboard.

When encountering errors in Python scripts, re-generating the client after an update may fix them.

Can I modify the generated client code?

Yes, but it is not recommended to make modifications to it, as update to Pulsonix may require re-installation of the pulsonix package.

You should instead use the package as a dependency for any additional functionality that you need.

You can also generate custom clients in several ways. See API Interaction for more information.

How can I solve a particular problem with Python scripting?

The Python documentation can answer questions about general language uses and library features. Python is distributed with a rich set of well documented libraries that provide file access, graphical interface tools and data processing functions. It also includes the pip module, which can be used to install additional libraries.

For high level guidance on how to use the Pulsonix Python client library, see Getting started with Python scripting.

For information on what API functionality is available via the Pulsonix Python client, see the Scripting Reference.

How can I make scripts run faster?

The largest overhead in typical scripts is making API calls, which are easy to detect in a script - each function and property access is an API call. Reduce total calls by:

  • Avoiding repeated calls for data which is not expected to change by storing the data in a client-side variable.
  • Avoiding API calls for tasks which can be done on the client-side.
  • Taking shortcuts to reduce API calls - for example, using GetAttributeValue instead of GetAttribute and then accessing the Attribute object’s Value property.

Client-side and server-side operations are generally much faster than the communication overhead, but to ensure that your own Python code is not the problem, use profiling tools such as Python’s built-in cProfile.

Where can I find examples?

Reference Python scripts are available in the Examples folder installed with the product.

Scripting overview | Getting started with Python scripting | Running Python Scripts | Scripting FAQ | Scripting Dashboard