The left-hand panel of the Python Script Editor is used to manage Python scripts.
Contents [Hide] |
You can use the Script List tab and the Script Folders tab on the left to manage all of your Python scripts.
Adding or deleting a script on one tab will also add or delete it on the other tab.
This tab displays all of the scripts in one list.
The Script List tab provides a toolbar for most functions and a search field below the list of scripts.
This tab displays all of the scripts in a folder structure.
On the Script Folders tab, right-click on a folder or script to display available functions - including commands to organize your scripts into folders.
Two scripts cannot have the same name, even if they are in different folders.
At least one script must be present before right-clicking on a folder will display the right-click menu. You can use the Script List tab to create that first script and then return to the Script Folders tab to work with scripts and folders.
You can use the Script List toolbar buttons (below) or the Script Folders right-click menu to create a new script.
On the Script List tab, click the (New) button on the toolbar to create a new blank script. (The new script will be added to the top-level [Scripts] folder on the Script Folders tab.)
On the Script Folders tab, right-click on a folder and then click New Script to create a new blank script in that folder.
On the Script List tab, select an existing script and then click the (Copy) button on the toolbar to make a copy of the script. (The new script will be added to the same folder as the original script on the Script Folders tab.)
On the Script Folders tab, right-click on a script and then click Copy to make a copy of the script in the same folder.
You can download sample Python scripts that were created for GainSeeker.
In many cases, you will need to modify the script to work correctly on your system. Look for comments in the downloaded script that provide instructions for these modifications. |
There is a separate Script Library for each type of Python script. These libraries are updated periodically.
To open the Python Script Library:
On the Script List tab, click the (Script Library) button on the toolbar. (The downloaded script will be added to the top-level [Scripts] folder on the Script Folders tab.)
On the Script Folders tab, right-click on a folder and then click Script Library.
(If you cannot access the script library, ask your IT department to grant you access to ftp://ftp.hertzler.com/python and its sub-folders.)
To download a sample Python script, select the script from the Python Scripts list and then click Add.
On the Script List tab, there are several ways to find a script in the list:
Click the list of scripts and begin typing the script name
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. (This computer will now default to searching by content instead of script name until you turn off this feature.)
Sort
the displayed scripts in order by name (Label),
Last Edit Date, Folder, or
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 five separate lists of Python scripts - scripts for data entry (via inspections or as standalone scripts), scripts for custom statistics, scripts for dashboards, SPC retrieval scripts, and DMS retrieval 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.
Browse to the folder that contains the desired script. (At this time, there is no Search function on the Script Folders tab.)
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.
Selecting a script on the Script
List tab or the Script
Folders tab will also select it on the other tab.
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 script names) to choose the selected script for the inspection test, dashboard control, or dynamic report.
You can use the Script Folders tab to organize your scripts into folders .
On the Script Folders tab, the top-level [Scripts] folder cannot be deleted or renamed.
All of your scripts will exist either in this folder or in one of the sub-folders you create.
Every folder - including the [Scripts] folder - can contain both scripts and other folders.
To create a new sub-folder in an existing folder, right-click on the existing folder and then click New Folder.
You can also right-click on a folder to:
Rename it.
Move it into a different folder.
Pin it to the Pinned Folders list for easy access. Each GainSeeker user has their own list of pinned folders.
To move a script to a different folder, right-click on the script and then click Move.
When a script is selected on the Script Folders tab, these details are displayed below the folder structure: its Folder, the Last Edit date/time, and the last GainSeeker User to edit it.
Before you edit or delete a script, best practice* is to investigate whether that script is run by any inspections, dashboards, retrievals, or other scripts - and ensure that the changes you make will not have an adverse effect. You can use the Script List toolbar buttons (below) or the Script Folders right-click menu to perform these checks.
To check for inspections, dashboards, and other scripts that may run a particular script:
On the Script List tab, select the script and then click the (Used By) button on the toolbar.
On the Script Folders tab, right-click on a script and click Used By.
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.
* Another best practice for safely editing a script is to archive it before editing. This keeps a record of previous code, so that you can go back to it if needed. You can archive the same script multiple times to keep a revision history of the script.
Archiving a script makes an offline backup of the current (live) script. You can archive the same script multiple times to keep a revision history of the script.
For each Python script in GainSeeker, you can use the Archive function to:
view any previously-archived versions of the script and view comments about those versions.
archive the current (live) version of the script and enter a comment about this version.
compare backups to each other and to the current (live) version of the script.
copy the code from a previous version of the script.
To archive the current version of any Python script, or to view any older archived copies of a script, you can use the Script List toolbar buttons (below) or the Script Folders right-click menu. You can also use the Script Folders right-click menu to archive all of the scripts in a folder and its sub-folders.
To begin:
On the Script List tab, select the script you want to work with and then click the (Archive) button on the toolbar.
On the Script Folders tab, right-click on the script you want to work with and then click Archive.
This will display the Manage Archive window for the script you just selected.
If there are no archived versions of this script,
[CURRENT SCRIPT]
will be the only script version listed.
If archived versions of this script already exist,
they will be listed here.
From this Manage Archive window, you can do the following:
To archive (back up) the
current version of the script, click Archive
Current Script.
GainSeeker will prompt you to enter an optional Archive
Message, where you can enter a note about this
version you are archiving. (You will not
be able to change or remove this Archive Message later.)
After clicking Save
for the Archive Message, GainSeeker will add a copy of
the current script to the list of archived versions of
the script.
Please note:
Archiving an Action-based script will store the equivalent code-only script.
There is not a function to delete any archived versions of a script.
To view or copy the code
for an archived version of the script, or to read the
full Archive Message
for that version, click on that archived version.
You can copy the code by clicking in the code viewer, pressing
CTRL+A to select all of the text, and then pressing CTRL+C
to copy all of the text to the Windows clipboard.
If you need to revert to one of these archived versions
of the script, you can use this method to copy the archived
code, then edit the current script to delete its code
and paste in this copied code (using CTRL+V).
To compare any two script
versions listed here (including the [CURRENT
SCRIPT]), use the CTRL or SHIFT key to select any
two script versions, and then click the Compare
button.
GainSeeker will save the contents of both versions as temporary
files and then use 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.
You can also use several methods to archive multiple scripts at once. GainSeeker will prompt you to enter an optional Archive Message, where you can enter a note about this version you are archiving and apply it to all of the scripts being archived.
In the Python Script Editor: click the Script Folders tab, right-click on a folder , and then click Archive. This will archive all of the scripts in a folder and its sub-folders.
Use the GainSeeker Inspections module to archive all scripts used by an inspection.
Use the GainSeeker Charts module to archive all scripts used by a dashboard.
Use the GainSeeker Utility module to archive all scripts used by the current configuration.
You can use the Script List toolbar buttons (below) to export and import a script.
You can also use the Script Folders right-click menu to export and import a script or a folder.
To export a script:
On the Script List tab, select the script to export, click the (Export) button on the toolbar, and enter a file name and location for the export file.
On the Script Folders tab, right-click on a script and click Export, then enter a file name and location for the export file.
To export a folder:
On the Script Folders
tab, right-click on a folder and click
Export Folder, then
enter a file name and location for the export file.
The exported folder will contain the name of the folder (not
its full path to the top-level [Scripts]
folder) and all of its sub-folders and scripts.
To import a script:
On the Script List tab, click the (Import) button on the toolbar and choose the file to import. (The new script will be added to the top-level [Scripts] folder on the Script Folders tab.)
On the Script Folders tab, right-click on a folder and click Import Script, then choose the file to import into that folder.
To import a folder:
On the Script Folders
tab, right-click on a folder and click
Import Folder, then
choose the file to import into that folder.
The imported folder and all of its sub-folders and scripts
will be added to the folder you right-clicked when beginning
the import.
You can use the Script List toolbar buttons (below) or the Script Folders right-click menu to copy scripts to a different configuration. The folder structure for each script will be replicated in the new configuration.
To begin:
On the Script List tab, click the (Copy to Configuration) button on the toolbar.
On the Script Folders
tab, right-click on a script or folder
and click Copy
to Configuration.
When you copy a folder
to a different configuration. all of the scripts in that folder
and its sub-folders will be selected for you on the next step.
When prompted, select the Target
configuration to receive the copied scripts, and select
one or more Scripts to copy.
If the target configuration already contains scripts with
these names, those scripts will be overwritten.
However, you can automatically archive
those scripts before they are overwritten. Select Archive
scripts replaced in target configuration and enter a message
to be stored with the archive.
Click Copy.
Sometimes you may need to compare two similar scripts and identify the differences between them. You can use the Script List toolbar buttons (below) or the Script Folders right-click menu to do so.
To begin:
On the Script List tab, select the first script for comparison and then click the (Compare) button on the toolbar.
On the Script Folders tab, right-click on the first script for comparison and then click Compare.
This will display the Select script to compare window and highlight the script you just selected:
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'.)
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.
Before deleting a script, consider creating a folder for "Unused" scripts and moving it to that folder instead. This prevents you from accidentally deleting a script that you may need later.
Otherwise, best practice for deleting a script - or all the scripts in a folder and its sub-folders - is to:
Investigate whether each script is run by any inspections, dashboards, retrievals, or other scripts.
Back up the script or folder by exporting the it to file.
To delete a script:
On the Script
List tab, select
the script you want to delete and then click the (Delete)
button on the toolbar.
On the Script Folders tab, right-click on a script and click Delete.
If necessary, you can also delete a folder.
Warning: Deleting a folder will delete all of the scripts in that folder
and all of its sub-folders. |
To delete all the scripts in a folder and its sub-folders, click on the Script Folders tab, right-click on the folder , and then click Delete.
If a script is locked, you will need to unlock it before you can delete it.
Please note than any Archived revisions of this script are not deleted, but they can only be accessed with a SQL script.