Python commands: Miscellaneous

The Miscellaneous commands in Python start and stop other processes that are not named in other command groups.

Note: These commands are not available for Custom Statistics or Device Profiles.

See Python commands for other commands you can use with GainSeeker.

Syntax

Example

Description/Remarks

New or changed in GainSeeker version

misc.executescript("scriptname", scripttype=0)

myvar1 = 345

misc.executescript("Show Result form")

myvar2 = "abc"

Sets a variable, runs the GainSeeker Inspections Module script named "Show Result form", and then sets another variable.

myvar1 = 345

misc.executescript("Show HTML", 1)

myvar2 = "abc"

Sets a variable, runs the Dashboard script named "Show HTML", and then sets another variable.

Executes a Python script. This can take the place of copying and pasting the same code into multiple scripts, and changes to that code only need to happen in one script.

The scripttype specifies the type of script being run. Valid options for this parameter are:

0 - GainSeeker Inspections module script. If no scripttype is specified, this one is used.

1 - Dashboard script

2 - SPC external data script

3 - DMS external data script

The script being called ("scriptname") must exist in the list of scripts identified by the scripttype parameter.

All variables, effects, etc. will carry back into the parent script.

The "scriptname" being called must only use commands and variables that the parent script can use. This means, for example,that  a dashboard script cannot execute an inspection script that runs any of the inspect commands. Therefore, common practice is to execute a "scriptname" of the same scripttype as the parent script.

Be careful not to create an endless loop by executing a script that calls the parent script, which again executes the script, which again calls the parent script, and so forth in a circular fashion. Such behavior can ultimately generate an error.

9.2

misc.parsecolumn(input, index, spliton="character(s)", isnumeric=True, noempty=False)

print misc.parsecolumn("Part#; Feature1; USpec; LSpec; Value1; A-50RB; Length; ; ; 0.503", 9, "; ", True, False)

Returns 0.503 as a number.

Splits the input into columns based on the character(s) specified by spliton. Returns the value for the specified column index returned by the split. Columns are zero based.

If isnumeric is True, the value to be returned should be a number.

If noempty is True, empty columns are automatically removed and are not counted for the column index.

 

misc.restart()

misc.restart()

Restarts the Python script from the beginning.

 

misc.run(target, waitforexit)

misc.run("C:\\temp\\sample.xlsx", True)

Uses the Windows default application for files with the .xlsx extension (such as Microsoft Excel) to open C:\temp\sample.xlsx .

Halts further script execution until the specified file (C:\temp\sample.xlsx) is closed.

Runs the specified application. If the file is not an executable, the default application for opening that file is launched.

If waitforexit is True, the script halts until the application closes.

 

misc.run(target, waitforexit, arguments)

misc.run("C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\EXCEL.EXE", True, "/x /e")

Launches Microsoft Excel from the specified folder, with arguments /x and /e .

Halts further script execution until the specified file (EXCEL.EXE) is closed.

Runs the specified application. If the file is not an executable, the default application for opening that file is launched.

If waitforexit is True, the script halts until the application closes.

You can specify command line arguments for the application when it launches.

 

misc.stop()

misc.stop()

Stops the execution of the Python script.

 

Script to automatically close and re-open a Desktop

To fully refresh a Dynamic Desktop, it is necessary to close the current charts and re-open the desktop. When chart display is unattended (e.g., using a large screen to display charts as a Slideshow), another approach is required.

This script terminates the currently-running GainSeeker Charts module and then launches it again with command line parameters to log in and open the desktop.

You could create a Windows Scheduled Task that launches the GSConsole module and runs this script.

 

import time

import os

while True:

    # taskkill - https://technet.microsoft.com/en-us/library/bb491009.aspx

    os.system("taskkill /f /im GSCharts.exe")

    misc.run("GSCharts.exe", False, "OpenType=0 Open=DesktopName UserName=\"SPC Manager\"")

    

    # time.sleep takes number of seconds - 30 mins is 60 * 30 = 1800

    time.sleep(1800)