improved logging with additional if statement
This commit is contained in:
parent
7b6b9d528f
commit
676f422d1f
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# openrefine-batch.sh, Felix Lohmeier, v0.6.1, 01.03.2017
|
||||
# openrefine-batch.sh, Felix Lohmeier, v0.6.2, 01.03.2017
|
||||
# https://github.com/felixlohmeier/openrefine-batch
|
||||
|
||||
# user input
|
||||
|
@ -9,7 +9,7 @@ if [ -z "$1" ]
|
|||
exit 2
|
||||
else
|
||||
inputdir=$(readlink -f $1)
|
||||
if [ ! -z "${inputdir// }" ] ; then
|
||||
if [ -n "${inputdir// }" ] ; then
|
||||
inputfiles=($(find -L ${inputdir}/* -type f -printf "%f\n" 2>/dev/null))
|
||||
fi
|
||||
fi
|
||||
|
@ -19,7 +19,7 @@ if [ -z "$2" ]
|
|||
exit 2
|
||||
else
|
||||
configdir=$(readlink -f $2)
|
||||
if [ ! -z "${configdir// }" ] ; then
|
||||
if [ -n "${configdir// }" ] ; then
|
||||
jsonfiles=($(find -L ${configdir}/* -type f -printf "%f\n" 2>/dev/null))
|
||||
fi
|
||||
fi
|
||||
|
@ -37,7 +37,7 @@ if [ -z "$4" ]
|
|||
exit 2
|
||||
else
|
||||
crossdir=$(readlink -f $4)
|
||||
if [ ! -z "${crossdir// }" ] ; then
|
||||
if [ -n "${crossdir// }" ] ; then
|
||||
crossprojects=($(find -L ${crossdir}/* -maxdepth 0 -type d -printf "%f\n" 2>/dev/null))
|
||||
fi
|
||||
fi
|
||||
|
@ -118,8 +118,8 @@ echo ""
|
|||
|
||||
# import all files
|
||||
if [ -n "$inputfiles" ]; then
|
||||
echo "=== IMPORT ==="
|
||||
echo ""
|
||||
echo "=== IMPORT ==="
|
||||
echo ""
|
||||
for inputfile in "${inputfiles[@]}" ; do
|
||||
echo "import ${inputfile}..."
|
||||
# run client with input command
|
||||
|
@ -140,17 +140,19 @@ echo ""
|
|||
done
|
||||
fi
|
||||
|
||||
echo "=== TRANSFORM / EXPORT ==="
|
||||
echo ""
|
||||
# transform and export files
|
||||
if [ -n "$jsonfiles" ] || [ "$export" = "export-true" ]; then
|
||||
echo "=== TRANSFORM / EXPORT ==="
|
||||
echo ""
|
||||
|
||||
# get project ids
|
||||
echo "get project ids..."
|
||||
projects=($(docker run --rm --link ${uuid} felixlohmeier/openrefine-client -H ${uuid} -l | tee ${outputdir}/projects.tmp | cut -c 2-14))
|
||||
cat ${outputdir}/projects.tmp && rm ${outputdir}/projects.tmp
|
||||
echo ""
|
||||
# get project ids
|
||||
echo "get project ids..."
|
||||
projects=($(docker run --rm --link ${uuid} felixlohmeier/openrefine-client -H ${uuid} -l | tee ${outputdir}/projects.tmp | cut -c 2-14))
|
||||
cat ${outputdir}/projects.tmp && rm ${outputdir}/projects.tmp
|
||||
echo ""
|
||||
|
||||
# provide additional OpenRefine projects for cross function
|
||||
if [ -n "$crossprojects" ]; then
|
||||
# provide additional OpenRefine projects for cross function
|
||||
if [ -n "$crossprojects" ]; then
|
||||
echo "provide additional projects for cross function..."
|
||||
# copy given projects to workspace
|
||||
rsync -a --exclude='*.project/history' $crossdir/*.project $outputdir
|
||||
|
@ -162,10 +164,10 @@ if [ -n "$crossprojects" ]; then
|
|||
until docker run --rm --link ${uuid} --entrypoint /usr/bin/curl felixlohmeier/openrefine-client --silent -N http://${uuid}:3333 | cat | grep -q -o "OpenRefine" ; do sleep 1; done
|
||||
docker attach ${uuid} &
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
|
||||
# loop for all projects
|
||||
for projectid in "${projects[@]}" ; do
|
||||
# loop for all projects
|
||||
for projectid in "${projects[@]}" ; do
|
||||
# time
|
||||
echo "--- begin project $projectid @ $(date) ---"
|
||||
echo ""
|
||||
|
@ -213,13 +215,14 @@ for projectid in "${projects[@]}" ; do
|
|||
# time
|
||||
echo "--- finished project $projectid @ $(date) ---"
|
||||
echo ""
|
||||
done
|
||||
done
|
||||
|
||||
# list output files
|
||||
if [ "$export" = "export-true" ]; then
|
||||
# list output files
|
||||
if [ "$export" = "export-true" ]; then
|
||||
echo "output (number of lines / size in bytes):"
|
||||
wc -c -l ${outputdir}/*.tsv
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
|
||||
# cleanup
|
||||
|
|
Loading…
Reference in New Issue