Class PythonSyntaxTest


  • public class PythonSyntaxTest
    extends java.lang.Object
    Performs a python syntax test.
    Author:
    Alexander Weber
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static boolean pyflakesExists
      If pyflakes is installed, assumed to be true.
      private static java.util.List<java.io.File> pythonFiles  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void getAllPythonServices​(java.lang.String directory)
      Give a list of files in a directory.
      static void main​(java.lang.String[] args)
      Runs a python command on CLI to evaluate the python service script on build time.
      static java.lang.String readProcessOutput​(java.io.InputStream stream)
      Shall take in input stream of processes to collect console output.
      static java.lang.String runPythonTest​(java.lang.String[] cmd)
      Running the syntax check for the python Files.
      • Methods inherited from class java.lang.Object

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

      • pyflakesExists

        private static boolean pyflakesExists
        If pyflakes is installed, assumed to be true.
      • pythonFiles

        private static java.util.List<java.io.File> pythonFiles
    • Constructor Detail

      • PythonSyntaxTest

        public PythonSyntaxTest()
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
                         throws java.util.concurrent.ExecutionException
        Runs a python command on CLI to evaluate the python service script on build time.
        Parameters:
        args - Args. No used.
        Throws:
        java.util.concurrent.ExecutionException - In case the Python file is not well build
      • runPythonTest

        public static java.lang.String runPythonTest​(java.lang.String[] cmd)
        Running the syntax check for the python Files.
        Parameters:
        cmd - the command to run, either utilising pyflaks or py_compile
        Returns:
        The output to add to the other outputs
      • readProcessOutput

        public static java.lang.String readProcessOutput​(java.io.InputStream stream)
                                                  throws java.io.IOException
        Shall take in input stream of processes to collect console output.
        Parameters:
        stream - Process to be observed.
        Returns:
        The read Lines from the process.
        Throws:
        java.io.IOException - If the reading of the lines does fail.
      • getAllPythonServices

        public static void getAllPythonServices​(java.lang.String directory)
        Give a list of files in a directory.
        Parameters:
        directory - the path to the directory as String.