java.lang.Object
com.inductiveautomation.ignition.common.script.builtin.SystemUtilities
Direct Known Subclasses:
DesignerSystemUtilities

public abstract class SystemUtilities extends Object
  • Field Details

    • DEFAULT_REQUEST_TIMEOUT

      protected static final int DEFAULT_REQUEST_TIMEOUT
      See Also:
    • LOG

      protected static final LoggerEx LOG
    • MSGLOG

      protected static final org.slf4j.Logger MSGLOG
    • MSGID_GENERATOR

      protected static final AtomicLong MSGID_GENERATOR
  • Constructor Details

    • SystemUtilities

      public SystemUtilities()
  • Method Details

    • execute

      public static void execute(String[] commands) throws IOException
      Executes a shell command
      Throws:
      IOException
    • getProperty

      public static String getProperty(String name)
      Simply delegates to System.getProperty()
    • beep

      public static void beep()
    • playSoundClip

      public static void playSoundClip(String wavFile) throws IOException
      Throws:
      IOException
    • threadDump

      public String threadDump() throws IOException
      Gets a thread dump from the JVM and returns as a string.
      Throws:
      IOException
    • _getCpuUsageString

      protected Double _getCpuUsageString(ThreadInfo threadInfo)
    • setLoggingLevel

      public static void setLoggingLevel(String loggerName, String loggerLevel) throws IOException
      Sets the logging level for the named logger.
      Throws:
      IOException
    • playSoundClip

      public static void playSoundClip(String wavFile, double volume, boolean wait) throws IOException
      Throws:
      IOException
    • playSoundClip

      public static void playSoundClip(byte[] soundData) throws IOException
      Throws:
      IOException
    • playSoundClip

      public static void playSoundClip(byte[] soundData, double volume, boolean wait) throws IOException
      Throws:
      IOException
    • invokeAsynchronous

      public final Thread invokeAsynchronous(org.python.core.PyObject[] args, String[] keywords)
    • _invokeAsyncImpl

      protected abstract Thread _invokeAsyncImpl(org.python.core.PyObject fun, org.python.core.PyObject[] args, String[] kwargs, @Nullable String description)
    • logger

      public static org.slf4j.Logger logger(String loggerName)
    • getLogger

      public static LoggerEx getLogger(String name)
    • jsonEncode

      public static String jsonEncode(org.python.core.PyObject pyObj) throws JSONException
      Encodes a PyObject into a JSON string. The conversion is as follows:
      • None into null
      • True into true
      • 42 into 42
      • 42L into 42
      • 42.0 into 42.0
      • {'hello': 1, 'world': 2} into {"hello": 1, "world": 2}
      • (1, 42, 'Hello world!') into [1, 42, "Hello world!"] .
      Returns:
      String
      Throws:
      JSONException
    • jsonEncode

      public static String jsonEncode(DatasetUtilities.PyDataSet dataSet) throws JSONException
      Throws:
      JSONException
    • jsonEncode

      public static String jsonEncode(org.python.core.PyObject pyObj, int indentFactor) throws JSONException
      Encodes a prettyprinted PyObject into a JSON string.
      Parameters:
      indentFactor - indentation per line
      Returns:
      String result from the encode
      Throws:
      JSONException
    • jsonEncode

      public static String jsonEncode(DatasetUtilities.PyDataSet dataSet, int indentFactor) throws JSONException
      Throws:
      JSONException
    • jsonDecode

      public static org.python.core.PyObject jsonDecode(String jsonString) throws JSONException
      Decodes a JSON String into a PyObject. The mapping of the JSON strings to PyObjects is the inverse of jsonEncode except that json Arrays get mapped to PyList only( no way to map back to python tuple). Also, JSON integers get mapped to PyIntegers unless they are greater than the maximum value of PyInteger, in which case they get mapped to PyLong. Floating point values are mapped to PyFloat.
      Parameters:
      jsonString - the JSON to decode.
      Returns:
      a PyObject, the structure of which reflects the decoded JSON.
      Throws:
      JSONException - if any errors occur decoding the provided JSON.
    • translate

      public String translate(org.python.core.PyObject[] args, String[] kwargs)
    • translateImpl

      @Nullable protected abstract 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,Boolean> parseTranslateArguments(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

      public void modifyTranslation(String term, String translation, String locale)
    • modifyTranslationImpl

      protected abstract void modifyTranslationImpl(@Nonnull String term, @Nonnull String translation, @Nullable String locale)
    • getSessionInfo

      public DatasetUtilities.PyDataSet getSessionInfo()
    • getSessionInfo

      public DatasetUtilities.PyDataSet getSessionInfo(String unameFilter)
    • getSessionInfo

      public DatasetUtilities.PyDataSet getSessionInfo(String unameFilter, String projectFilter)
    • getSessionInfo

      public DatasetUtilities.PyDataSet getSessionInfo(org.python.core.PyObject[] values, String[] keywords)
    • _getSessionInfo

      public abstract DatasetUtilities.PyDataSet _getSessionInfo(String unameFilter, String projectFilter)
    • 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

      public Object sendRequest(org.python.core.PyObject[] values, String[] keywords) throws Exception
      Throws:
      Exception
    • sendRequestAsync

      public Request sendRequestAsync(org.python.core.PyObject[] values, String[] keywords) throws Exception
      Throws:
      Exception
    • sendRequestInternal

      protected Request sendRequestInternal(org.python.core.PyObject[] values, String[] keywords, boolean async)
    • sendRequestInternal

      protected abstract Request sendRequestInternal(String project, String messageHandler, org.python.core.PyDictionary payload, Properties params, boolean async)
    • getGatewayStatus

      public String getGatewayStatus(org.python.core.PyObject[] values, String[] keywords)
    • getVersion

      public Version getVersion() throws Exception
      Throws:
      Exception
    • getVersionInternal

      protected abstract Version getVersionInternal() throws Exception
      Throws:
      Exception
    • audit

      public abstract void audit(org.python.core.PyObject[] args, String[] keywords)