Class SystemUtilities

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  SystemUtilities.RequestImpl
      This is the base implementation of the "Result" object of system.util.sendRequestAsync.
    • Constructor Summary

      Constructors 
      Constructor Description
      SystemUtilities()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.Double _getCpuUsageString​(java.lang.management.ThreadInfo threadInfo)  
      abstract DatasetUtilities.PyDataSet _getSessionInfo​(java.lang.String unameFilter, java.lang.String projectFilter)  
      protected abstract java.lang.Thread _invokeAsyncImpl​(org.python.core.PyObject fun, org.python.core.PyObject[] args, java.lang.String[] kwargs, java.lang.String description)  
      abstract void audit​(org.python.core.PyObject[] args, java.lang.String[] keywords)  
      static void beep()  
      static void execute​(java.lang.String[] commands)
      Executes a shell command
      java.lang.String getGatewayStatus​(org.python.core.PyObject[] values, java.lang.String[] keywords)  
      static LoggerEx getLogger​(java.lang.String name)  
      static java.lang.String getProperty​(java.lang.String name)
      Simply delegates to System.getProperty()
      DatasetUtilities.PyDataSet getSessionInfo()  
      DatasetUtilities.PyDataSet getSessionInfo​(java.lang.String unameFilter)  
      DatasetUtilities.PyDataSet getSessionInfo​(java.lang.String unameFilter, java.lang.String projectFilter)  
      DatasetUtilities.PyDataSet getSessionInfo​(org.python.core.PyObject[] values, java.lang.String[] keywords)  
      Version getVersion()  
      protected abstract Version getVersionInternal()  
      java.lang.Thread invokeAsynchronous​(org.python.core.PyObject[] args, java.lang.String[] keywords)  
      static org.python.core.PyObject jsonDecode​(java.lang.String jsonString)
      Decodes a JSON String into a PyObject.
      static java.lang.String jsonEncode​(DatasetUtilities.PyDataSet dataSet)  
      static java.lang.String jsonEncode​(DatasetUtilities.PyDataSet dataSet, int indentFactor)  
      static java.lang.String jsonEncode​(org.python.core.PyObject pyObj)
      Encodes a PyObject into a JSON string.
      static java.lang.String jsonEncode​(org.python.core.PyObject pyObj, int indentFactor)
      Encodes a prettyprinted PyObject into a JSON string.
      static org.slf4j.Logger logger​(java.lang.String loggerName)  
      void modifyTranslation​(java.lang.String term, java.lang.String translation, java.lang.String locale)  
      protected abstract void modifyTranslationImpl​(java.lang.String term, java.lang.String translation, java.lang.String locale)  
      static org.apache.commons.lang3.tuple.Triple<java.lang.String,​java.lang.String,​java.lang.Boolean> parseTranslateArguments​(org.python.core.PyObject[] args, java.lang.String[] kwargs)
      Parse keyword arguments to the translate function.
      static void playSoundClip​(byte[] soundData)  
      static void playSoundClip​(byte[] soundData, double volume, boolean wait)  
      static void playSoundClip​(java.lang.String wavFile)  
      static void playSoundClip​(java.lang.String wavFile, double volume, boolean wait)  
      java.util.List<java.lang.String> sendMessage​(org.python.core.PyObject[] values, java.lang.String[] keywords)  
      abstract java.util.List<java.lang.String> sendMessageInternal​(java.lang.String project, java.lang.String messageHandler, org.python.core.PyDictionary payload, java.util.Properties filterParams)  
      java.lang.Object sendRequest​(org.python.core.PyObject[] values, java.lang.String[] keywords)  
      Request sendRequestAsync​(org.python.core.PyObject[] values, java.lang.String[] keywords)  
      protected abstract Request sendRequestInternal​(java.lang.String project, java.lang.String messageHandler, org.python.core.PyDictionary payload, java.util.Properties params, boolean async)  
      protected Request sendRequestInternal​(org.python.core.PyObject[] values, java.lang.String[] keywords, boolean async)  
      static void setLoggingLevel​(java.lang.String loggerName, java.lang.String loggerLevel)
      Sets the logging level for the named logger.
      java.lang.String threadDump()
      Gets a thread dump from the JVM and returns as a string.
      java.lang.String translate​(org.python.core.PyObject[] args, java.lang.String[] kwargs)  
      protected abstract java.lang.String translateImpl​(java.lang.String term, java.lang.String locale, boolean strict)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_REQUEST_TIMEOUT

        protected static final int DEFAULT_REQUEST_TIMEOUT
        See Also:
        Constant Field Values
      • LOG

        protected static final LoggerEx LOG
      • MSGLOG

        protected static final org.slf4j.Logger MSGLOG
      • MSGID_GENERATOR

        protected static final java.util.concurrent.atomic.AtomicLong MSGID_GENERATOR
    • Constructor Detail

      • SystemUtilities

        public SystemUtilities()
    • Method Detail

      • execute

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

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

        public static void beep()
      • playSoundClip

        public static void playSoundClip​(java.lang.String wavFile)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • threadDump

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

        protected java.lang.Double _getCpuUsageString​(java.lang.management.ThreadInfo threadInfo)
      • setLoggingLevel

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

        public static void playSoundClip​(java.lang.String wavFile,
                                         double volume,
                                         boolean wait)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • playSoundClip

        public static void playSoundClip​(byte[] soundData)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • playSoundClip

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

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

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

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

        public static LoggerEx getLogger​(java.lang.String name)
      • jsonEncode

        public static java.lang.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 java.lang.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
      • jsonDecode

        public static org.python.core.PyObject jsonDecode​(java.lang.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 java.lang.String translate​(org.python.core.PyObject[] args,
                                          java.lang.String[] kwargs)
      • translateImpl

        @Nullable
        protected abstract java.lang.String translateImpl​(@Nonnull
                                                          java.lang.String term,
                                                          @Nullable
                                                          java.lang.String locale,
                                                          boolean strict)
                                                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • parseTranslateArguments

        public static org.apache.commons.lang3.tuple.Triple<java.lang.String,​java.lang.String,​java.lang.Boolean> parseTranslateArguments​(org.python.core.PyObject[] args,
                                                                                                                                                     java.lang.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​(java.lang.String term,
                                      java.lang.String translation,
                                      java.lang.String locale)
      • modifyTranslationImpl

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

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

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

        public abstract DatasetUtilities.PyDataSet _getSessionInfo​(java.lang.String unameFilter,
                                                                   java.lang.String projectFilter)
      • sendMessage

        public java.util.List<java.lang.String> sendMessage​(org.python.core.PyObject[] values,
                                                            java.lang.String[] keywords)
                                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendMessageInternal

        public abstract java.util.List<java.lang.String> sendMessageInternal​(java.lang.String project,
                                                                             java.lang.String messageHandler,
                                                                             org.python.core.PyDictionary payload,
                                                                             java.util.Properties filterParams)
                                                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendRequest

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

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

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

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

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

        public Version getVersion()
                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getVersionInternal

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

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