Class SystemUtilities
java.lang.Object
com.inductiveautomation.ignition.common.script.builtin.SystemUtilities
- Direct Known Subclasses:
DesignerSystemUtilities
Provides core system functions exposed as system.util.* in scripting.
These functions are available across all Ignition scopes, although some implementations may vary depending on whether they are running in a Gateway, Client, or Designer context.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Double_getCpuUsageString(ThreadInfo threadInfo) abstract Dataset_getSessionInfo(String unameFilter, String projectFilter) protected abstract Thread_invokeAsyncImpl(org.python.core.PyObject fun, org.python.core.PyObject[] args, String[] kwargs, @Nullable String description) abstract voidstatic voidbeep()static voidExecutes a shell command on the host operating system.getGatewayStatus(org.python.core.PyObject[] values, String[] keywords) static LoggerExstatic StringgetProperty(String name) Returns the string value of the system property with the specified name.getSessionInfo(String unameFilter) getSessionInfo(String unameFilter, String projectFilter) getSessionInfo(org.python.core.PyObject[] values, String[] keywords) protected abstract Versionfinal ThreadinvokeAsynchronous(org.python.core.PyObject[] args, String[] keywords) Invokes the provided Python function in a background thread.static org.python.core.PyObjectjsonDecode(String jsonString) Decodes a JSON string into aPyObject.static StringjsonEncode(DatasetUtilities.PyDataSet dataSet) static StringjsonEncode(DatasetUtilities.PyDataSet dataSet, int indentFactor) static StringjsonEncode(org.python.core.PyObject pyObj) Encodes aPyObjectinto a JSON string.static StringjsonEncode(org.python.core.PyObject pyObj, int indentFactor) Encodes aPyObjectinto a JSON string with optional pretty-printing.static org.slf4j.LoggervoidmodifyTranslation(String term, String translation, String locale) protected abstract voidmodifyTranslationImpl(@NonNull String term, @NonNull String translation, @Nullable String locale) parseTranslateArguments(org.python.core.PyObject[] args, String[] kwargs) Parse keyword arguments to the translate function.static voidplaySoundClip(byte[] soundData) static voidplaySoundClip(byte[] soundData, double volume, boolean wait) static voidplaySoundClip(String wavFile) static voidplaySoundClip(String wavFile, double volume, boolean wait) sendMessage(org.python.core.PyObject[] values, String[] keywords) sendMessageInternal(String project, String messageHandler, org.python.core.PyDictionary payload, Properties filterParams) sendRequest(org.python.core.PyObject[] values, String[] keywords) sendRequestAsync(org.python.core.PyObject[] values, String[] keywords) protected final CompletableFuture<Object>sendRequestInternal(PyArgumentMap args, boolean async) protected abstract CompletableFuture<Object>sendRequestInternal(String project, String messageHandler, @Nullable org.python.core.PyDictionary payload, Properties params) static voidsetLoggingLevel(String loggerName, String loggerLevel) Sets the logging level for the named logger.Gets a thread dump from the JVM and returns as a string.protected abstract @Nullable StringtranslateImpl(@NonNull String term, @Nullable String locale, boolean strict)
-
Field Details
-
DEFAULT_REQUEST_TIMEOUT
protected static final int DEFAULT_REQUEST_TIMEOUT -
LOG
-
MSGLOG
-
-
Constructor Details
-
SystemUtilities
public SystemUtilities()
-
-
Method Details
-
execute
Executes a shell command on the host operating system.- Parameters:
commands- An array of strings representing the command and its arguments.- Throws:
IOException- If an I/O error occurs during command execution.
-
getProperty
Returns the string value of the system property with the specified name.- Parameters:
name- The name of the system property.- Returns:
- The string value of the system property, or
nullif it doesn't exist.
-
beep
public static void beep() -
playSoundClip
- Throws:
IOException
-
threadDump
Gets a thread dump from the JVM and returns as a string.- Throws:
IOException
-
_getCpuUsageString
-
setLoggingLevel
Sets the logging level for the named logger. -
playSoundClip
- Throws:
IOException
-
playSoundClip
- Throws:
IOException
-
playSoundClip
- Throws:
IOException
-
invokeAsynchronous
Invokes the provided Python function in a background thread.This is useful for long-running operations that would otherwise block the main thread (e.g., the UI thread in a Client or Designer). Note that any operations that modify the UI from the background thread must be wrapped in
system.util.invokeLater.- Parameters:
args- The arguments to the function, including 'function', 'args', 'kwargs', and 'description'.- Returns:
- The
Threadthat was created to run the function.
-
_invokeAsyncImpl
-
logger
-
getLogger
-
jsonEncode
Encodes aPyObjectinto a JSON string.The conversion rules are as follows:
NoneintonullTrue/Falseintotrue/false- Python numbers (int, long, float) into JSON numbers
- Dictionaries into JSON objects
- Sequences (list, tuple) into JSON arrays
Datasetobjects are converted into a JSON object with 'columns' and 'rows'
- Parameters:
pyObj- The Python object to encode.- Returns:
- A JSON string representation of the object.
- Throws:
JSONException- If an error occurs during encoding.
-
jsonEncode
- Throws:
JSONException
-
jsonEncode
public static String jsonEncode(org.python.core.PyObject pyObj, int indentFactor) throws JSONException Encodes aPyObjectinto a JSON string with optional pretty-printing.- Parameters:
pyObj- The Python object to encode.indentFactor- The number of spaces to use for indentation in pretty-printing.- Returns:
- A JSON string representation of the object.
- Throws:
JSONException- If an error occurs during encoding.
-
jsonEncode
public static String jsonEncode(DatasetUtilities.PyDataSet dataSet, int indentFactor) throws JSONException - Throws:
JSONException
-
jsonDecode
Decodes a JSON string into aPyObject.The mapping is the inverse of
jsonEncode(PyObject), with the caveat that JSON arrays are always decoded asPyLists.- Parameters:
jsonString- The JSON string to decode.- Returns:
- A
PyObjectrepresenting the decoded JSON data. - Throws:
JSONException- If the provided string is not valid JSON.
-
translate
-
translateImpl
protected abstract @Nullable String translateImpl(@NonNull String term, @Nullable String locale, boolean strict) throws Exception - Throws:
Exception
-
parseTranslateArguments
public static org.apache.commons.lang3.tuple.Triple<String,String, parseTranslateArgumentsBoolean> (org.python.core.PyObject[] args, String[] kwargs) Parse keyword arguments to the translate function. Broken into a unique function to avoid duplication in other, more specific contexts.- Returns:
- A Triple containing the term, locale, and whether the 'strict' flag was passed.
- Throws:
org.python.core.PyException- if there was an error parsing the arguments. Should be thrown directly.
-
modifyTranslation
-
modifyTranslationImpl
-
getSessionInfo
-
getSessionInfo
-
getSessionInfo
-
getSessionInfo
-
_getSessionInfo
-
sendMessage
public List<String> sendMessage(org.python.core.PyObject[] values, String[] keywords) throws Exception - Throws:
Exception
-
sendMessageInternal
public abstract List<String> sendMessageInternal(String project, String messageHandler, org.python.core.PyDictionary payload, Properties filterParams) throws Exception - Throws:
Exception
-
sendRequest
- Throws:
Exception
-
sendRequestAsync
-
sendRequestInternal
-
sendRequestInternal
protected abstract CompletableFuture<Object> sendRequestInternal(String project, String messageHandler, @Nullable org.python.core.PyDictionary payload, Properties params) -
getGatewayStatus
-
getVersion
- Throws:
Exception
-
getVersionInternal
- Throws:
Exception
-
audit
-