Skip to content

Commit

Permalink
#1045 - auto-speed option for datatable run
Browse files Browse the repository at this point in the history
  • Loading branch information
kensoh committed Jun 4, 2021
1 parent 0945279 commit 5783ca0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
19 changes: 8 additions & 11 deletions src/tagui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ chrome_command="google-chrome"

if [ -z "$1" ]
then
echo "tagui v6.41: use following options and this syntax to run - ./tagui flow_filename option(s)"
echo "tagui v6.42: use following options and this syntax to run - ./tagui flow_filename option(s)"
echo
echo "tagui live launch TagUI live mode enabled with visual automation for interactive development"
echo "input(s) add your own parameter(s) to be used in your automation flow as variables p1 to p8"
Expand Down Expand Up @@ -180,7 +180,7 @@ if [ "$7" = "-report" ] || [ "$7" = "-r" ]; then set -- "${@:1:6}" "${@:8}"; tag
if [ "$8" = "-report" ] || [ "$8" = "-r" ]; then set -- "${@:1:7}" "${@:9}"; tagui_html_report=true; fi
if [ "$9" = "-report" ] || [ "$9" = "-r" ]; then set -- "${@:1:8}"; tagui_html_report=true; fi

tagui_speed_mode=false
tagui_speed_mode=true
# check speed parameter to skip delay and chrome restart between iterations
if [ "$2" = "-speed" ] || [ "$2" = "-s" ]; then set -- "$1" "${@:3}"; tagui_speed_mode=true; fi
if [ "$3" = "-speed" ] || [ "$3" = "-s" ]; then set -- "${@:1:2}" "${@:4}"; tagui_speed_mode=true; fi
Expand Down Expand Up @@ -259,9 +259,6 @@ else tagui_data_set_size="$(($min_column-1))"; fi; fi
for (( tagui_data_set=1; tagui_data_set<=$tagui_data_set_size; tagui_data_set++ ))
do export tagui_data_set=$tagui_data_set

# add delay between repetitions to pace out iterations
if [ "$tagui_data_set" -ne 1 ] && [ "$tagui_speed_mode" == false ]; then sleep 3; fi

# parse automation flow file, check for initial parse error
# check R, python, sikuli, chrome, before calling casperjs
php -q tagui_parse.php "$1" | tee -a "$1".log
Expand Down Expand Up @@ -346,14 +343,14 @@ if [ -f "tagui_py/tagui_py.in" ]; then echo "finish" > tagui_py/tagui_py.in; fi
if [ -f "tagui.sikuli/tagui_sikuli.in" ]; then echo "finish" > tagui.sikuli/tagui_sikuli.in; fi
if [ -f "tagui_chrome.in" ]; then echo "finish" > tagui_chrome.in; fi

# kill chrome processes by checking which os the processes are started on
if [ "$chrome_started" == "Darwin" ] && [ "$tagui_speed_mode" == false ]; then
chrome_process_id="$(ps x | grep remote-debugging-port=9222 | grep tagui_user_profile | grep window-size | sed -e 's/^[ ]*//' | cut -d' ' -f 1 | sort -nur | head -n 1)"
if [ -n "$chrome_process_id" ]; then kill $chrome_process_id; fi
else if [ -n "$chrome_started" ] && [ "$tagui_speed_mode" == false ]; then
# add delay between repetitions to pace out iterations
if [ "$tagui_data_set_size" -ne 1 ]; then sleep 3; fi

# kill chrome processes on single first run or data set last run
if [ "$tagui_data_set" -eq "$tagui_data_set_size" ]; then
chrome_process_id="$(ps x | grep remote-debugging-port=9222 | grep tagui_user_profile | grep window-size | sed -e 's/^[ ]*//' | cut -d' ' -f 1 | sort -nur | head -n 1)"
if [ -n "$chrome_process_id" ]; then kill $chrome_process_id; fi
fi; fi
fi

# end of big loop for managing multiple data sets in datatable
done
Expand Down
14 changes: 7 additions & 7 deletions src/tagui.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rem enable windows for loop advanced flow control
setlocal enableextensions enabledelayedexpansion

if "%~1"=="" (
echo tagui v6.41: use following options and this syntax to run - tagui flow_filename option^(s^)
echo tagui v6.42: use following options and this syntax to run - tagui flow_filename option^(s^)
echo.
echo tagui live launch TagUI live mode enabled with visual automation for interactive development
echo input^(s^) add your own parameter^(s^) to be used in your automation flow as variables p1 to p8
Expand Down Expand Up @@ -746,7 +746,7 @@ if "%arg9%"=="-r" (
set tagui_html_report=true
)

set tagui_speed_mode=false
set tagui_speed_mode=true
rem check speed parameter to skip delay and chrome restart between iterations
if "%arg2%"=="-speed" (
set arg2=
Expand Down Expand Up @@ -911,9 +911,6 @@ rem big loop for managing multiple data sets in datatable
for /l %%n in (1,1,%tagui_data_set_size%) do (
set tagui_data_set=%%n

rem add delay between repetitions to pace out iterations
if !tagui_data_set! neq 1 if %tagui_speed_mode%==false php -q sleep.php 3

rem parse automation flow file, check for initial parse error
rem check R, python, sikuli, chrome, before calling casperjs
php -q tagui_parse.php "%flow_file%" | tee -a "%flow_file%.log"
Expand Down Expand Up @@ -1012,8 +1009,11 @@ if exist "tagui_py\tagui_py.in" echo finish > tagui_py\tagui_py.in
if exist "tagui.sikuli\tagui_sikuli.in" echo finish > tagui.sikuli\tagui_sikuli.in
if exist "tagui_chrome.in" echo finish > tagui_chrome.in

rem kill chrome processes by checking which os the processes are started on
if not "!chrome_started!"=="" if %tagui_speed_mode%==false (
rem add delay between repetitions to pace out iterations
if !tagui_data_set_size! neq 1 php -q sleep.php 3

rem kill chrome processes on single first run or data set last run
if !tagui_data_set! equ !tagui_data_set_size! (
for /f "tokens=* usebackq" %%p in (`wmic process where "caption like '%%chrome.exe%%' and commandline like '%%tagui_user_profile_ --remote-debugging-port=9222%%'" get processid 2^>nul ^| cut -d" " -f 1 ^| sort -nur ^| head -n 1`) do set chrome_process_id=%%p
if not "!chrome_process_id!"=="" taskkill /PID !chrome_process_id! /T /F > nul 2>&1
)
Expand Down

0 comments on commit 5783ca0

Please sign in to comment.