CInbox (Common-Inbox)  0.1
Common functionality for ingesting files for archiving.
 All Classes Functions Variables
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
TaskExec Class Reference
Inheritance diagram for TaskExec:
CITask TaskFFmpeg TaskPostProcs TaskPreProcs TaskPreProcs2 TaskPreProcs2

Public Member Functions

 __construct (&$CIFolder)
 
- Public Member Functions inherited from CITask
 __construct (&$CIFolder, $label)
 
 getName ()
 
 setLabel ($label)
 
 getLabel ()
 
 setDescription ($description)
 
 getDescription ()
 
 skip ()
 
 skipIt ()
 
 setItemSubDirs ($itemSubDirs)
 
 getStatus ()
 
 statusUndefined ()
 
 statusRunning ()
 
 statusWait ()
 
 statusDone ()
 
 statusPBCT ()
 
 statusPBC ()
 
 statusSkipped ()
 
 statusError ()
 
 statusConfigError ()
 
 init ()
 
 run ()
 
 finalize ()
 

Public Attributes

const TASK_LABEL = 'Execute external programs (abstract)'
 
Exit codes

Exit-codes of external scripts that represent task states. Task states STATUS_RUNNING and STATUS_UNDEFINED are internal only and therefore not available to external program execution.

NOTE: These numbers are not mapped 1:1 to task states, because application exit codes are defined as: 0 = okay non-0 = error Yet, the same numbers were used wherever possible.

IMPORTANT: All programs/scripts executed by this task must implement these exit codes. Otherwise, a non-0 exitcode might lead to undesired, possibly catastrophic results. If you need to execute an arbitrary program, please use a wrapper-script of some kind to return these exit codes as desired.

const EXIT_STATUS_DONE = 0
 Success! This means the task completed successfully.
 
const EXIT_STATUS_WAIT = 5
 Task decided that Item is not ready yet and shall be moved back to 'to-do'.
 
const EXIT_STATUS_PBCT = 6
 There were problems, but the task may continue.
 
const EXIT_STATUS_PBC = 7
 There were problems, but subsequent task may continue.
 
const EXIT_STATUS_ERROR = 10
 An error occurred. Abort execution as soon as possible.
 
const EXIT_STATUS_CONFIG_ERROR = 11
 If a config option was not valid.
 
const EXIT_STATUS_SKIPPED = 15
 If task was skipped.
 
- Public Attributes inherited from CITask
const STATUS_UNDEFINED = 0
 Undefined. Default unless task changes it.
 
const STATUS_RUNNING = 1
 Undefined, but indicates that the task is in progress.
 
const STATUS_WAIT = 2
 Task decided that Item is not ready yet and shall be moved back to 'to-do'.
 
const STATUS_DONE = 5
 Success! This means the task completed successfully.
 
const STATUS_PBCT = 6
 There were problems, but the task may continue.
 
const STATUS_PBC = 7
 There were problems, but subsequent task may continue.
 
const STATUS_ERROR = 10
 An error occurred. Abort execution as soon as possible.
 
const STATUS_CONFIG_ERROR = 11
 If a config option was not valid.
 
const STATUS_SKIPPED = 15
 If task was skipped.
 
const ONCE_PER_ITEM = false
 True: Run this task only once per item.
 
const IS_RECURSIVE = false
 Default (false): one task = one folder. True: The task performs actions on subfolders too.
 
const CONF_COPY_EXCLUDE = 'COPY_EXCLUDE'
 Patterns which files to exclude from copying.
 
const MASK_TARGET_TEMP = 'temp_%s'
 

Protected Member Functions

 isCmdValid ($command)
 
 resolveCmd ($command, $arguments=null)
 
 runScript ($script)
 
 setStatusByExitcode ($exitCode)
 
 getCmdLogfile ($prefix=null)
 
 removeCmdLogfile ($logFile=null)
 
 writeToCmdLogfile ($msg, $logFile=null)
 
- Protected Member Functions inherited from CITask
 setName ($name)
 
 exclude ($file, $excludePatterns)
 
 optionIsArray ($option, $optionName)
 
 resolveTargetFolderTemp ($CIFolder=null)
 
 setStatus ($status)
 
 setStatusUndefined ()
 
 setStatusRunning ()
 
 setStatusWait ()
 
 setStatusDone ()
 
 setStatusPBCT ()
 
 setStatusPBC ()
 
 setStatusSkipped ()
 
 setStatusError ()
 
 setStatusConfigError ()
 
 checkTempFolder ()
 
 getTempFolder ()
 
 setTempFolder ($tempFolder=null)
 
 loadSettings ()
 

Protected Attributes

 $exec
 
 $logFile
 
- Protected Attributes inherited from CITask
 $logger
 Logging handler.
 
 $name
 Class name of this task.
 
 $label
 Human readable Task label.
 
 $description
 Human readable description of Task's purpose/actions.
 
 $CIFolder
 CIFolder object that provides all information needed for this task.
 
 $sourceFolder
 Source folder of this task.
 
 $targetFolder
 Target folder of this task (read from config).
 
 $targetFolderTemp
 Temporary name of Target folder of this task. Used until inbox processing completed successfully.
 
 $itemSubDirs
 Array of Item subfolders: key=foldername, value=CIFolder (initialized with its config).
 
 $tempFolder
 Path of the temp folder for this task.
 
 $copyExclude
 Contains the value of CONF_COPY_EXCLUDE.
 
 $skip = false
 True: Skip execution. Default=false (=normal execution).
 
 $status
 Status of this task (=for current item subfolder).
 

Additional Inherited Members

- Static Public Member Functions inherited from CITask
static isRecursive ()
 
static oncePerItem ()
 
static getTaskByName ($taskName, $CIFolder)
 
static getTaskClassName ($taskName)
 
- Static Protected Attributes inherited from CITask
static $statusGlobal
 Status of the sum of tasks of this type. // TODO! Implement and use this.
 

Detailed Description

Abstract base class for tasks that call external applications.

Author
Peter Bubestinger-Steindl (pb@av.nosp@m.-rd..nosp@m.com)
See also

Member Function Documentation

TaskExec::getCmdLogfile (   $prefix = null)
protected

Get filename of logfile to use for external command execution. Filename is "$prefix + DATEIME" (TIME precision: seconds). If $prefix is empty, the task name will be used.

NOTE: Assumes $this->tempFolder to be set and initialized.

Parameters
$prefix[string] String to prefix logfile name with.

: self::checkTempFolder()

TaskExec::isCmdValid (   $command)
protected

Takes a commandline string consisting of program and arguments and checks if the program file exists and is executable.

TaskExec::removeCmdLogfile (   $logFile = null)
protected

Removes/deletes the logfile used for external command execution. self::getCmdLogfile()

TaskExec::resolveCmd (   $command,
  $arguments = null 
)
protected

Resolves placeholders in command string.

TaskExec::runScript (   $script)
protected

Takes the name of a shell-script (or any other command), and executes it after resolving placeholders e.g. as arguments.

TaskExec::setStatusByExitcode (   $exitCode)
protected

Sets the task status according to the given exitcode. This can be used to have external scripts determine tasklist flow.

TaskExec::writeToCmdLogfile (   $msg,
  $logFile = null 
)
protected

Used to write a message to the command execution logfile. Appends if file already exists, otherwise creates it before.

Member Data Documentation

TaskExec::$logFile
protected

$logFile: Contains filename for output of external command execution. But should only be used if exactly 1 command is called once per class instantiation. Otherwise, please resolve logfile name using getCmdLogfile() right before executing the external application.


The documentation for this class was generated from the following file: