Script.pm

Summary
Script.pm
BE4::ScriptDescribe a script, its weight and allowed to write in.
Constructors
newScript constructor.
Getters - Setters
getIDReturns the script’s identifiant
isExecutedAlone
getTempDirReturns the script’s temporary directories
getMntConfDirReturns the mergeNtiff configuration’s directory
getDntConfDirReturns the decimateNtiff configuration’s directory
getWeightReturns the script’s weight
addWeightAdd provided weight to script’s weight.
setWeightDefine the script’s weight.
Stream methods
prepareWrite script’s header, which contains environment variables: the script ID, path to work directory, cache...
writePrint text in the script’s file, using the opened stream.
close
Export methods
exportForDebugReturns all informations about the script.

BE4::Script

Exporter
BE4::Script

Describe a script, its weight and allowed to write in.

Using

use BE4::Script;

my $objC = BE4::Script->new({
    id => "SCRIPT_1",
    tempDir => "/home/ign/TMP/",
    commonTempDir => "/home/ign/TMP/",
    scriptDir => "/home/ign/SCRIPTS",
    executedAlone => "FALSE"
});

Attributes

idstring - Identifiant, like “SCRIPT_2”.  It used to name the file and temporary directories.
executedAloneboolean - If we know a script will be executed ALONE. it can change some working.
filePathstring - Complete absolute script file path.
tempDirstring - Directory used to write temporary images.
commonTempDirstring - Directory used to write temporary images which have to be shared between different scripts.
mntConfDirstring - Directory used to write mergeNtiff configuration files.  mntConfDir is a subdirectory of commonTempDir.
dntConfDirstring - Directory used to write decimateNtiff configuration files (used by NNGraph generation).  dntConfDir is a subdirectory of commonTempDir.
currentweightinteger - Current weight of the script (already written in the file)
weightinteger - Total weight of the script, according to its content.
streamstream - Stream to the script file, to write in.
Summary
Constructors
newScript constructor.
Getters - Setters
getIDReturns the script’s identifiant
isExecutedAlone
getTempDirReturns the script’s temporary directories
getMntConfDirReturns the mergeNtiff configuration’s directory
getDntConfDirReturns the decimateNtiff configuration’s directory
getWeightReturns the script’s weight
addWeightAdd provided weight to script’s weight.
setWeightDefine the script’s weight.
Stream methods
prepareWrite script’s header, which contains environment variables: the script ID, path to work directory, cache...
writePrint text in the script’s file, using the opened stream.
close
Export methods
exportForDebugReturns all informations about the script.

Constructors

new

sub new

Script constructor.  Bless an instance.

Parameters (hash)

idstring - Identifiant, used to name the file, like ‘SCRIPT_1’.
scriptDirstring - Directory path, where to write the script.
tempDirstring - Root directory, in which own temporary directory will be created.
commonTempDirstring - Common temporary directory, to allowed scripts to share files
executedAloneboolean - Optionnal, FALSE by default.

Getters - Setters

getID

sub getID

Returns the script’s identifiant

isExecutedAlone

sub isExecutedAlone

getTempDir

sub getTempDir

Returns the script’s temporary directories

getMntConfDir

sub getMntConfDir

Returns the mergeNtiff configuration’s directory

getDntConfDir

sub getDntConfDir

Returns the decimateNtiff configuration’s directory

getWeight

sub getWeight

Returns the script’s weight

addWeight

sub addWeight

Add provided weight to script’s weight.

Parameters (list)

weightinteger - weight to add to script’s one.

setWeight

sub setWeight

Define the script’s weight.

Parameters (list)

weightinteger - weight to set as script’s one.

Stream methods

prepare

sub prepare

Write script’s header, which contains environment variables: the script ID, path to work directory, cache...  And functions to factorize code.

Parameters (list)

pyrDirstring - Pyramid root directory.
listFilestring - Path to the list file.
functionsstring - Configured functions, used in the script (mergeNtiff, wget...).

Example

# Variables d'environnement
SCRIPT_ID="SCRIPT_1"
COMMON_TMP_DIR="/tmp/ORTHO/COMMON"
ROOT_TMP_DIR="/tmp/ORTHO/"
TMP_DIR="/tmp/ORTHO/SCRIPT_1"
MNT_CONF_DIR="/home/ign/TMP/ORTHO/SCRIPT_1/mergeNtiff"
DNT_CONF_DIR="/home/ign/TMP/ORTHO/SCRIPT_1/decimateNtiff"
PYR_DIR="/home/ign/PYR/ORTHO"
LIST_FILE="/home/ign/PYR/ORTHO.list"

# fonctions de factorisation
Wms2work () {
  local img_dst=$1
  local url=$2
  local count=0; local wait_delay=60
  while :
  do
    let count=count+1
    wget --no-verbose -O $img_dst $url
    if tiffck $img_dst ; then break ; fi
    echo "Failure $count : wait for $wait_delay s"
    sleep $wait_delay
    let wait_delay=wait_delay*2
    if [ 3600 -lt $wait_delay ] ; then
      let wait_delay=3600
    fi
  done
}

write

sub write

Print text in the script’s file, using the opened stream.

Parameters (list)

textstring - Text to write in file.

close

sub close

Export methods

exportForDebug

sub exportForDebug

Returns all informations about the script.  Useful for debug.

Example

Object BE4::Script :
    ID : SCRIPT_2
    Will NOT be executed alone
    Script path : /home/IGN/SCRIPTS/SCRIPT_2.sh
    Temporary directory : /home/IGN/TEMP/SCRIPT_2
    Common temporary directory : /home/IGN/TEMP/COMMON
    MergeNtiff configuration directory : /home/IGN/TEMP/COMMON/mergeNtiff
    DecimateNtiff configuration directory : /home/IGN/TEMP/COMMON/decimateNtiff
    Weight : 59
sub new
Script constructor.
sub getID
Returns the script’s identifiant
sub isExecutedAlone
sub getTempDir
Returns the script’s temporary directories
sub getMntConfDir
Returns the mergeNtiff configuration’s directory
sub getDntConfDir
Returns the decimateNtiff configuration’s directory
sub getWeight
Returns the script’s weight
sub addWeight
Add provided weight to script’s weight.
sub setWeight
Define the script’s weight.
sub prepare
Write script’s header, which contains environment variables: the script ID, path to work directory, cache...
sub write
Print text in the script’s file, using the opened stream.
sub close
sub exportForDebug
Returns all informations about the script.
Representation of a “nearest neighbour” pyramid : pyramid’s image = Node.
Close