Merge branch 'master' of git+ssh://gitbox/piccreate
This commit is contained in:
+7
-40
@@ -10,6 +10,7 @@ Usage: `basename $0` [-h] [-i] [-j nb_jobs] command arg_list
|
||||
-c give the path to the cfg file
|
||||
-i give the path of the svg files without the last /
|
||||
-k chek if the jpg already exist
|
||||
-s set the sleeptime while there are too many simultanious jobs
|
||||
-j Set number of simultanious jobs. Default is 2
|
||||
-o directory where the files should be moved to after creation.
|
||||
Default ist PICCREATE_OUT
|
||||
@@ -17,40 +18,10 @@ Usage: `basename $0` [-h] [-i] [-j nb_jobs] command arg_list
|
||||
`basename $0` -i file -c config
|
||||
`basename $0` -j 3 -i file -c config"
|
||||
|
||||
function queue {
|
||||
QUEUE="$QUEUE $1"
|
||||
NUM=$(($NUM+1))
|
||||
}
|
||||
function regeneratequeue {
|
||||
OLDREQUEUE=$QUEUE
|
||||
QUEUE=""
|
||||
NUM=0
|
||||
for PID in $OLDREQUEUE
|
||||
do
|
||||
if [ -d /proc/$PID ] ; then
|
||||
QUEUE="$QUEUE $PID"
|
||||
NUM=$(($NUM+1))
|
||||
fi
|
||||
done
|
||||
}
|
||||
function checkqueue {
|
||||
OLDCHQUEUE=$QUEUE
|
||||
for PID in $OLDCHQUEUE
|
||||
do
|
||||
if [ ! -d /proc/$PID ] ; then
|
||||
regeneratequeue # at least one PID has finished
|
||||
echo $PID
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
function cfg_parser {
|
||||
INI_FILE=$1
|
||||
SECTION=$2
|
||||
echo $1
|
||||
echo $2
|
||||
eval `sed -n -e "/^\[$SECTION\]/,/^\s*\[/{/^[^;].*\=.*/p;}" < $INI_FILE`>> trr.txt
|
||||
echo 'helololo'
|
||||
}
|
||||
function get_filepath {
|
||||
# probiere alle möglichen Kombinationen wo das file stehen könnte je
|
||||
@@ -116,8 +87,9 @@ if [ $# -eq 0 ]; then # must be at least one arg
|
||||
fi
|
||||
|
||||
CHECKFILE=0
|
||||
SLEEPTIME=0.5
|
||||
|
||||
while getopts "j:i:kc:o:hc:" OPT; do # "j:" waits for an argument "h" doesnt
|
||||
while getopts "j:i:kc:s:o:hc:" OPT; do # "j:" waits for an argument "h" doesnt
|
||||
case $OPT in
|
||||
h) echo "$USAGE"
|
||||
exit 0 ;;
|
||||
@@ -125,6 +97,7 @@ while getopts "j:i:kc:o:hc:" OPT; do # "j:" waits for an argument "h" doesnt
|
||||
k) CHECKFILE=1 ;;
|
||||
c) CFG_FILENAME=$OPTARG ;;
|
||||
o) OUTDIR=$OPTARG ;;
|
||||
s) SLEEPTIME=$OPTARG ;;
|
||||
i) INPUT_FILENAME=$OPTARG ;;
|
||||
*) echo "$USAGE" >&2; exit 1; # Default.
|
||||
esac
|
||||
@@ -139,27 +112,21 @@ check_params
|
||||
echo $INPUT_FILE
|
||||
for i in `ls $INPUT_FILE| grep .svg `
|
||||
do
|
||||
echo $i
|
||||
echo $CHECKFILE
|
||||
ID=`echo "$i" | sed -e 's/;.*//g'`
|
||||
PIC_NAME=`echo "$i" | sed -e 's/.svg/.jpg/g'`
|
||||
FILE_PATH=$INPUT_FILE/$PIC_NAME
|
||||
if [ -s $FILE_PATH ] && [ $CHECKFILE -eq 1 ]
|
||||
then
|
||||
echo $PIC_NAME exists!
|
||||
echo $PIC_NAME exists
|
||||
else
|
||||
RESIZE="${width}x${height}"
|
||||
SWITCHES="-density $density $INPUT_FILE/$ID -resize $RESIZE $INPUT_FILE/$PIC_NAME"
|
||||
CMDLINE="$CMD $SWITCHES"
|
||||
echo $CMDLINE
|
||||
(echo $ID; $CMDLINE) &
|
||||
|
||||
PID=$!
|
||||
queue $PID
|
||||
|
||||
while [ $NUM -ge $MAX_NPROC ]; do
|
||||
checkqueue
|
||||
sleep 0.5
|
||||
while [ `ps -clx|grep -w 'convert' |wc -l` -ge $MAX_NPROC ]; do
|
||||
sleep $SLEEPTIME
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user