[clitk-commits-list] Clitk branch master updated. v1.2.0-607-gf54492f
root
root at tux.creatis.insa-lyon.fr
Mon Dec 19 14:22:47 CET 2011
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Clitk".
The branch, master has been updated
via f54492f7ac7d30e35ad953fe9f8c485bbb98c36d (commit)
from 3c2462eafabcf428b4d2775c414a7b5f62511d3f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.creatis.insa-lyon.fr/pubgit/?p=clitk.git;a=commitdiff;h=f54492f7ac7d30e35ad953fe9f8c485bbb98c36d
commit f54492f7ac7d30e35ad953fe9f8c485bbb98c36d
Author: Romulo Pinho <romulo.pinho at lyon.unicancer.fr>
Date: Mon Dec 19 14:22:17 2011 +0100
more robust motion mask script
diff --git a/scripts/create_midP_masks-2.0.sh b/scripts/create_midP_masks-2.0.sh
index 5bd0c9f..292ff3c 100755
--- a/scripts/create_midP_masks-2.0.sh
+++ b/scripts/create_midP_masks-2.0.sh
@@ -145,6 +145,68 @@ mm_postprocessing()
create_registration_masks
}
+wait_mm_creation()
+{
+ # the motion masks are first created in a tmp directory. this directory is
+ # later going to be renamed to the final motion mask directory. concurrent
+ # executions trying to create the same set of masks will be blocked until
+ # the first execution finishes. naturally, these other executions will not
+ # recreate the masks. so first we try to create the tmp directory.
+ # if the creation fails, it means that another execution is
+ # already creating the masks, so this execution will be blocked. the
+ # execution is unblocked only when the creation of masks is finished and
+ # the mask directory is renamed.
+ #
+ do_mm=1
+ if [ -e $mask_dir ]; then
+ # check that the final mask dir exists and that it contains all files it needs.
+ # the check assumes that the inside and outside masks are the key files to exist.
+ do_mm=0
+ nb_phases=${#phase_nbs[@]}
+ nb_in_masks=`ls $mask_dir/mask_in*.mhd | wc -l`
+ nb_out_masks=`ls $mask_dir/mask_out*.mhd | wc -l`
+ if [ $nb_in_masks != $nb_phases -o $nb_out_masks != $nb_phases ]; then
+ # if the mask dir is invalid, remove it and recreate all masks, just in case.
+ rm -fr $mask_dir 2> /dev/null
+ do_mm=1
+ fi
+ fi
+
+ if [ $do_mm = 1 ]; then
+ if ! mkdir $mask_dir_tmp 2> /dev/null; then
+ if [ ! -e $mask_dir_tmp ]; then
+ # if the temp dir couldn't be created, but it doesn't exist, abort
+ abort_on_error wait_mm_creation $? clean_up_masks
+ else
+ # assumes another process is creating the maks in the temp dir.
+ # now we need to wait until the masks are complete or until the
+ # time limit is reached.
+ interval=10
+ sleeping=0
+ max_wait=3600 # one hour
+ nb_files0=`ls $mask_dir_tmp/* | wc -l`
+ while [ ! -e $mask_dir -a $sleeping -le $max_wait ]; do
+ echo "waiting creation of motion masks..."
+ sleep $interval
+ sleeping=$(( $sleeping + $interval ))
+ nb_files1=`ls $mask_dir_tmp/* | wc -l`
+ if [ $nb_files1 != $nb_files0 ]; then
+ nb_files0=$nb_files1
+ sleeping=0
+ fi
+ done
+
+ if [ $sleeping -gt $max_wait ]; then
+ abort_on_error wait_mm_creation -1 clean_up_masks
+ else
+ echo "finished waiting"
+ do_mm=0
+ fi
+ fi
+ fi
+ fi
+}
+
motion_mask()
{
#set cmd line variables
@@ -180,35 +242,8 @@ motion_mask()
echo "start: $start"
echo
- # the motion masks are first created in a tmp directory. this directory is
- # later going to be renamed to the final motion mask directory. concurrent
- # executions trying to create the same set of masks will be blocked until
- # the first execution finishes. naturally, these other executions will not
- # recreate the masks. so first we try to create the tmp directory.
- # if the creation fails, it means that another execution is
- # already creating the masks, so this execution will be blocked. the
- # execution is unblocked only when the creation of masks is finished and
- # the mask directory is renamed.
- #
- # ATTENTION: RP - 08/02/2011
- # robustness issue: tmp directory may exist but may be empty or
- # incomplete. the solution is to check per file, but I'll leave it like
- # this for the moment.
- do_mm=0
- if [ $(ls -d $mask_dir 2> /dev/null | wc -l) -eq 0 ]; then
- mkdir $mask_dir_tmp 2> /dev/null
- return_mkdir=$?
- if [ $return_mkdir == 0 ]; then
- do_mm=1
- else
- while [[ $(ls -d $mask_dir 2> /dev/null | wc -l) -eq 0 ]]; do
- echo "waiting creation of motion masks..."
- sleep 2
- done
- echo "finished waiting"
- fi
- fi
-
+ wait_mm_creation
+
# do_mm=1
# mask_dir_tmp=$mask_dir
if [ $do_mm == 1 ]; then
-----------------------------------------------------------------------
Summary of changes:
scripts/create_midP_masks-2.0.sh | 93 ++++++++++++++++++++++++++------------
1 files changed, 64 insertions(+), 29 deletions(-)
hooks/post-receive
--
Clitk
More information about the Clitk-commits-list
mailing list