Refactored auto-recording function

This commit is contained in:
butomo1989 2017-10-30 20:42:36 +01:00
parent 08ff64d950
commit 0ea71ea6b8

View file

@ -9,37 +9,39 @@ function start() {
function stop() { function stop() {
echo "Stop video recording" echo "Stop video recording"
kill $(ps -ef | grep ffmpeg | awk '{print $2}') kill $(ps -ef | grep [f]fmpeg | awk '{print $2}')
} }
function auto_record() { function auto_record() {
if [ $AUTO_RECORD ]; then echo "Auto record: $AUTO_RECORD"
if [ ${AUTO_RECORD,,} = true ]; then sleep 6
echo "Auto recording is enable. It will record the video automatically as soon as appium receive test scenario!"
# Check if there is test running while [ $AUTO_RECORD == "True" ]; do
no_test=true # Check if there is test running
while $no_test; do no_test=true
task=$(curl -s localhost:4723/wd/hub/sessions | jq -r '.value') while $no_test; do
if [ -n $task ]; then task=$(curl -s localhost:4723/wd/hub/sessions | jq -r '.value')
sleep .5 if [ "$task" == "" ] || [ "$task" == "[]" ]; then
else sleep .5
no_test=false else
start start &
fi no_test=false
done fi
done
# Check if test is finished # Check if test is finished
while [ $no_test = false ]; do while [ $no_test == false ]; do
task=$(curl -s localhost:4723/wd/hub/sessions | jq -r '.value') task=$(curl -s localhost:4723/wd/hub/sessions | jq -r '.value')
if [ -n $task ]; then if [ "$task" == "" ] || [ "$task" == "[]" ]; then
stop stop
else no_test=true
sleep .5 else
fi sleep .5
done fi
fi done
fi done
echo "Auto recording is disabled!"
} }
$@ $@