The left-hand panel of the Python Script Editor is used to manage Python scripts.
Contents [Hide] |
There are several ways to find a script in the list:
Search by script name - Type a portion of the script name into the search field below the list of scripts.
Search by script contents - Click the icon at the end of the search field, click Search Content, and then type a portion of the script contents into the search field.
Sort the displayed scripts in order by name (Label), by Last Edit Date, or by Last Editor.
Click on one of these column headers to sort by that column; click that same column header again to reverse the sort order.
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.
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.
If you are currently editing the Formula test in an Inspection or a Python Dashboard Control in a Dashboard, you must also click the Select button (below the search field) to choose the selected script for the inspection test or dashboard control.
You can use toolbar buttons to create a new script.
Click the (New) toolbar button to create a new blank script.
Select an existing script, and then click the (Copy) toolbar button to make a copy of the script.
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.
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.
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 some of these checks.
To check for inspections that run an inspection script, or to check for dashboards that run a dashboard 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.
To check for other scripts that use misc.executescript to run a particular script:
Select the script and then click the (Used By) button.
This will find scripts that run misc.executescript("selected_script_name") and misc.executescript('selected_script_name') .
Run a search by contents and enter the script name.
This will find scripts that set the script name as a variable which may later be run as misc.executescript("variable_name") .
Before editing or deleting an inspection script, check for any dashboards that may run this script in a DateTime control (OverdueAction property) or in a Button control (ClickAction property).
Other tips and best practices for revision control of scripts:
Before editing a script, back it up by copying the script.
You can edit either the original or the new copy, knowing that you can still go back to the previous code if needed.
Before deleting a script, back it up by exporting the script to file.
If you later discover that you need the script again, it will be much easier to import the script than to re-create it from memory.
Lock any script that is used in production - by an inspection or dashboard, by another script, or as a standalone script.
This will prevent that script from being accidentally deleted.
Best practice for deleting a script is to:
Investigate whether that script is run by any inspections, dashboards, other scripts.
Back up the script by exporting the script to file.
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.