Class PythonCommand

java.lang.Object
org.variantsync.diffdetective.shell.ShellCommand
org.variantsync.diffdetective.shell.PythonCommand

public class PythonCommand extends ShellCommand
Command for running a python script with arguments. This class provides a builder like API to add arguments passed to the python script which can be interpreted by a specified python version.
  • Field Details

    • DiffDetectiveVenv

      public static String DiffDetectiveVenv
      Path to the python interpreter of the virtual environment (relative to the project/Git root).
    • pythonName

      private final String pythonName
    • script

      private final Path script
    • args

      private final List<String> args
  • Constructor Details

    • PythonCommand

      public PythonCommand(String commandName, Path script)
      Constructs a shell command running a python script with arguments.
      Parameters:
      commandName - a path to the python interpreter used to interpret script
      script - the python script to be executed
  • Method Details

    • addArg

      public PythonCommand addArg(String arg)
      Pass the additional argument arg to the python script.
    • addArg

      public PythonCommand addArg(Object o)
      Pass the additional argument o.toString() to the python script.
    • Python

      public static PythonCommand Python(Path script)
      Constructs a python command interpreting script with the default python version installed. Note that this should only be used for testing or in a reproducible environment (for example Docker) to ensure correct functionality on all supported platforms.
      See Also:
    • Python3

      public static PythonCommand Python3(Path script)
      Constructs a python command interpreting script with the installed python 3 version. Note that this should only be used for testing or in a reproducible environment (for example Docker) to ensure correct functionality on all supported platforms.
      See Also:
    • DiffDetectiveVenvPython3

      public static PythonCommand DiffDetectiveVenvPython3(Path script)
      Constructs a python command interpreting script with the python version installed in the virtual environment of DiffDetective. It should be safe to use this python version on all supported platform given that the virtual environment was set up correctly, which this method just assumes without checking.
      See Also:
    • parts

      public String[] parts()
      Description copied from class: ShellCommand
      Returns the String parts that define and configure the command execution. The first array entry is a path to an executable file. The others are arguments for that executable.

      Example: ["echo", "Hello World"]

      Specified by:
      parts in class ShellCommand
      Returns:
      the parts of the shell command.