Managing Python Scripts

The left-hand panel of the Python Script Editor is used to manage Python scripts.

 

Contents  [Hide]

 

Finding and selecting a script

Finding the desired script

There are several ways to find a script in the list:

Note: GainSeeker maintains three separate lists of Python scripts - scripts for custom statistics, scripts for dashboards, and scripts for data entry (via inspections or as standalone scripts). This means that a script you create for inspections will not be displayed when you are working with dashboard scripts or custom statistic scripts, for example.

Selecting a script

      1. Click the name of the script to select it.

        When a script is selected, you can edit, debug, lock, copy, export, or delete the script.

      2. If you are currently editing the Formula test in an Inspection, a Python Dashboard Control in a Dashboard, or a Scripted DMS or Scripted SPC Retrieval in Dynamic Reports 2, you must also click the Select button (below the search field) to choose the selected script for the inspection test, dashboard control, or dynamic report.

Creating a new script

You can use toolbar buttons to create a new script.

Creating a new Blank script

Click the (New) toolbar button to create a new blank script.

Copying an existing script

Select an existing script, and then click the (Copy) toolbar button to make a copy of the script.

Downloading a script from the Python Script Library

You can download sample Python scripts that were created for GainSeeker. In some cases, you will need to look for comments in the downloaded script that provide instructions for modifying the script to work correctly on your system.

The Script Library for data entry - inspections and standalone scripts - is different from the Script Library for dashboards. (There is also a Script Library for custom statistics.) These lists are updated periodically.

Click the  (Script Library) toolbar button to open the Python Script Library.

To import a sample Python script, select the script from the Python Scripts list and then click Add.

Importing and Exporting scripts

You can use toolbar buttons to import and export scripts.

To import a script: click the (Import) button and choose the file to import.

To export a script: select the script to export, click the (Export) button, and enter a file name and location for the export file.

Comparing scripts

Sometimes you may need to compare two similar scripts and identify the differences between them. You can use a toolbar button to do so.

    1. Select the first script for comparison and then click the (Compare) button on the toolbar.

      This will display the Select script to compare window and highlight the script you just selected:

    2. If you need to change to a different configuration to view the second script, select it from the Configuration list.
      (This list is only available if you have rights to 'See all users, roles, and configurations'.)

    3. Select the second script for comparison, and then click OK.

GainSeeker saves the contents of both scripts as temporary files and then uses an external script comparison program to compare them.

 

By default, GainSeeker uses fc.exe - a file comparison tool that is included with the Windows operating system - to compare the contents of the two scripts. You can use the Inspection Editor Settings to configure this workstation for a different file comparison tool such as Winmerge.

Checking for script usage and Controlling revisions

Before you edit or delete a script, best practice is to investigate whether that script is run by any inspections, dashboards, other scripts - and ensure that the changes you make will not have an adverse effect. You can use a toolbar button to perform these checks.

To check for inspections, dashboards, and other scripts that may run a particular script, select the script and then click the (Used By) button.

Note: If you have multiple configurations with separate tables for inspections or dashboards but the same table for scripts, you should also log in to those configurations and run this check.

Other tips and best practices for revision control of scripts:

Deleting scripts

Best practice for deleting a script is to:

    1. Investigate whether that script is run by any inspections, dashboards, other scripts.

    2. Back up the script by exporting the script to file.

    3. Select the script you want to delete and then click the (Delete) button on the toolbar.



      If the script is locked, you will need to unlock it before you can delete it.