Class PythonJob

java.lang.Object
org.codelibs.fess.job.ExecJob
org.codelibs.fess.job.PythonJob

public class PythonJob extends ExecJob
Job for executing Python scripts within the Fess search engine environment. This job extends ExecJob to provide Python-specific functionality for running Python scripts with proper environment setup and argument passing.

Python scripts are executed in the WEB-INF/env/python/resources directory and have access to the Fess system environment including OpenSearch URL and session ID.

  • Field Details

    • filename

      protected String filename
      The Python script filename to execute
    • argList

      protected List<String> argList
      List of command-line arguments to pass to the Python script
  • Constructor Details

    • PythonJob

      public PythonJob()
      Default constructor for PythonJob. Creates a new instance of the Python job with default settings.
  • Method Details

    • filename

      public PythonJob filename(String filename)
      Sets the Python script filename to execute.
      Parameters:
      filename - the Python script filename (relative to WEB-INF/env/python/resources)
      Returns:
      this PythonJob instance for method chaining
    • arg

      public PythonJob arg(String value)
      Adds a single command-line argument to pass to the Python script.
      Parameters:
      value - the argument value to add
      Returns:
      this PythonJob instance for method chaining
    • args

      public PythonJob args(String... values)
      Adds multiple command-line arguments to pass to the Python script.
      Parameters:
      values - the argument values to add
      Returns:
      this PythonJob instance for method chaining
    • execute

      public String execute()
      Executes the Python script job. Creates a session ID, sets up the execution environment, and runs the Python script with the configured filename and arguments.
      Specified by:
      execute in class ExecJob
      Returns:
      a string containing the execution result and any error messages
    • executePython

      protected void executePython()
      Executes the Python script with the configured parameters. Sets up the command list, working directory, and environment variables, then starts the Python process and waits for completion.
      Throws:
      JobProcessingException - if the Python script execution fails
    • getPyFilePath

      protected String getPyFilePath()
      Constructs the file path for the Python script to execute. The path is relative to the web application root and follows the pattern: WEB-INF/env/python/resources/{filename}
      Returns:
      the constructed file path for the Python script
    • getExecuteType

      protected String getExecuteType()
      Returns the execution type identifier for Python jobs.
      Specified by:
      getExecuteType in class ExecJob
      Returns:
      the execution type constant for Python jobs