Note

  • In PLANTA Project, the so-called Headless Client is used to create a batch job.

Step 1: Create a User in PLANTA project

Procedure

Step 2: Create/Install a Macro with the Required Functionality

Procedure

  • Create a new module in the Modules module
  • Adjust Python macro for the intended purpose.
  • For the batch user, this module can be defined as Startup macro which is run every time this user logs on.
    • Alternatively, you can specify the module ID in the start script of the headless client in the PLANTA_MODULE parameter (see here).

Step 3: Start the Headless Client Manually in Order to Create the Password File

Procedure

  • Open template
    • Note: this command, as well as its following examples, are single-rowed and may only be split for readability purposes:

<Python interpreter> <Headless path>planta_headless.py --service=<Server>:<Port> --user=<BATCH-User> --auth_type=challenge --secret=<PW file>

ParametersDescriptionExample for WindowsExample for Linux
<Python interpreter>Open the resp. Python interpreterC:\Python27\python.exe/usr/local/bin/python2.7
<Headless path>Directory path headless clients, absolute:
or based on the current directory:
C:\PLANTA\Jobs\Headless\
.\
/planta/jobs/headless/
./
<Server>Name or IP address of the PLANTA serverlocalhost (if executed on application server)
planta4711.planta.de
10.210.47.11
localhost (if executed on application server)
planta4711.planta.de
10.210.47.11
<Port>Connection port to the serviceStandard is 21000 + System no., e.g. 21001Standard is 21000 + System no., e.g. 21001
<BATCH user>Name of the PLANTA project batch userBATCHBATCH
<PW file>Path and name of the password file to be generated.\auth_file./auth_file


Example for Windows

C:\Python27\python.exe C:\PLANTA\Jobs\Headless\planta_headless.py --service=planta4711:21001 --user=BATCH --auth_type=challenge --secret=C:\PLANTA\Jobs\Headless\auth_file

Example for Linux

/usr/local/bin/python2.7 ./planta_headless.py --service=localhost:21210 --user=BATCH --auth_typechallenge --secret=./auth_file

  • Password input (password is saved in an encrypted file)
  • Set the rights for the newly created encrypted password file (editing/reading rights only for the user running the Python program).

Step 4: Configure Job

Procedure

  • For this purpose, adjust the following Shell/Batch script templates:
    • For the following script, enter the appropriate values in the Adjust parameter: section
    • Save as a file (e.g. named Headless.bat under Windows or named headless.bsh under Linux) in the headless cient directory (the date stamp here depends on the local format and must be adjusted if necessary).
  • Example for Windows
@ECHO OFF
REM BATCH
REM PLANTA Headless-Client: execution of batch jobs
REM Adjust parameters:
REM --->
SET PYTHON="<Path to Python (V. 2.6 oder 2.7)>"
SET HEADLESS_DIR="<Path to the headless client (PLANTA_PY)>"
SET SERVICE=<Server address:port number>
SET USER=BATCH
REM If the work package is defined as the batchuser's start module, this parameter remains empty,
REM otherwise the module ID of the module to be executed is entered here:
SET PLANTA_MODULE=
IF NOT "%PLANTA_MODULE%"=="" SET MODULE_PARAM=--module=%PLANTA_MODULE%
IF "%PLANTA_MODULE%"=="" SET MODULE_PARAM=
REM If logging is desired, activate the following variables,
REM and activate script call with logging below and deactivate the one without logging:
REM SET LOG_DIR="<Path of the log directory>"
REM SET LOGFILE="<Prefix for the log file (e.g. PLANTA_Headless)>"
REM SET DATETIME=%DATE:~-4%-%DATE:~3,2%-%DATE:~0,2%_%TIME:~0,2%-%TIME:~3,2%-%TIME:~6,2%
REM <---
SET AUTH_FILE=".\auth_file"
SET PLANTA_PY=".\planta_headless.py"
SET PLANTA_SH=%PLANTA_PY% --service=%SERVICE% --user=%USER% --auth_type=challenge --secret=%AUTH_FILE% %MODULE_PARAM%
cd %HEADLESS_DIR%
REM Variant without logging:
%PYTHON% %PLANTA_SH% %*
REM Variante with logging:
REM forfiles -p %LOG_DIR% -m %LOGFILE%*.log -d -7 -c "cmd /c del @path"
REM %PYTHON% %PLANTA_SH% %* --timeout=-1 -vvv >> %LOG_DIR%\%LOGFILE%_%DATETIME%_%USER%.log
BASH
  • Example for Linux:
#!/bin/bash
# PLANTA Headless-Client: execution of batch jobs
# Adjust parameters:
# --->
PYTHON="<Path to Python (V. 2.6 oder 2.7)>"
HEADLESS_DIR="<Path to the headless client (PLANTA_PY)>"
SERVICE="<Server address:port no.>"
USER="BATCH"
# If the work package is defined as the batchuser's start module, this parameter remains empty,
# otherwise the module ID of the module to be executed is entered here:
PLANTA_MODULE=""

if [[ -z $PLANTA_MODULE ]]
then
    MODULE_PARAM=""
else
    MODULE_PARAM="--module=$PLANTA_MODULE"
fi

# If logging is desired, activate the following variables,
# and activate script call with logging below and deactivate the one without logging:
#LOG_DIR="<Path of the log directory"
#LOGFILE="<Prefix for the log file name (e.g. PLANTA_Headless)>"
#DATETIME=`date +20%y-%m-%d_%H-%M-%S`
# <---
AUTH_FILE="./auth_file"
PLANTA_PY="planta_headless.py"
PLANTA_SH="./$PLANTA_PY --service=$SERVICE --user=$USER --auth_type=challenge --secret=$AUTH_FILE $MODULE_PARAM"
cd $HEADLESS_DIR
# Variant without logging:
$PYTHON $PLANTA_SH $*
# Variant with logging:
#find $LOG_DIR -type f -name "$LOGFILE*.log" -mtime +7 -print0 | xargs -0 rm -f
#$PYTHON $PLANTA_SH $* --timeout=-1 -vvv >> $LOG_DIR/$LOGFILE\_$DATETIME\_$USER.log
BASH

Step 5: Configure the Time-Controlled Start

Note

  • Here, administrator rights are required.

Procedure

  • Setup
    • under Windows: via Task Manager (or Task Planning)
    • under Linux: as a Cron Job
  • In both cases, the job has no information about environment variables, etc. All information it requires must be included in the shell-scripts (e.g. using absolute paths).

Note

  • The headless client usually starts a PLANTA macro without waiting for its completion.
  • This can be prevented via the timeout=-1 parameter.
  • In this case, the headless client waits for the macro to be completed.
  • See also the logging variant in the shell scripts mentioned above.