From 9e901864322cbac42601b5de39b0e989273cbdbf Mon Sep 17 00:00:00 2001 From: Oleg Sheynin Date: Wed, 24 Jul 2024 13:30:17 -0400 Subject: [PATCH] progress --- release_version.txt | 2 +- scripts/alpaca_hist_md/alpaca_md_day.sh | 27 +++++++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/release_version.txt b/release_version.txt index 90a27f9..af0b7dd 100644 --- a/release_version.txt +++ b/release_version.txt @@ -1 +1 @@ -1.0.5 +1.0.6 diff --git a/scripts/alpaca_hist_md/alpaca_md_day.sh b/scripts/alpaca_hist_md/alpaca_md_day.sh index f2183d8..bab516d 100755 --- a/scripts/alpaca_hist_md/alpaca_md_day.sh +++ b/scripts/alpaca_hist_md/alpaca_md_day.sh @@ -29,14 +29,26 @@ else fi if [ "${date_to_load}" == "next" ] ; then if [ ! -e ${LastDayFile} ]; then - mv ${LastDayFile}.prev ${LastDayFile} - if [ ! -e ${LastDayFile} ]; then - echo "file ${LastDayFile} does not exist" + echo "File ${LastDayFile} does not exist. Will try to use prev file." + if [ ! -e ${LastDayFile}.prev ]; then + echo "File ${LastDayFile}.prev does not exist. Aborted." exit 2 fi + mv ${LastDayFile}.prev ${LastDayFile} fi - last_date=$(cat ${LastDayFile}) - if [ -z ${last_date} ] ; then + last_date=$(cat ${LastDayFile} | xargs) + if [ -z "${last_date}" ] ; then + echo "File ${LastDayFile} returned an empty last day. Will try to use prev file." + if [ ! -e ${LastDayFile}.prev ]; then + echo "File ${LastDayFile}.prev does not exist. Aborted." + exit 2 + fi + mv ${LastDayFile}.prev ${LastDayFile} + last_date=$(cat ${LastDayFile} | xargs) + if [ -z "${last_date}" ] ; then + echo "Unable to obtain last_date. Aborted" + exit 3 + fi echo "No last date_to_load in ${LastDayFile}" exit 1 fi @@ -47,6 +59,7 @@ else fi Cmd="docker run" +Cmd="${Cmd} --pull" Cmd="${Cmd} --network=host" Cmd="${Cmd} --name=${ContainerName}" Cmd="${Cmd} --rm" @@ -60,7 +73,9 @@ if [ "$?" != "0" ] ; then exit 1 # if killed we do not save last day fi -if [ -n ${date_to_load} ]; then +# truncate to avoid false positive +date_to_load=$(echo "${date_to_load} | xargs") +if [ -n "${date_to_load}" ]; then echo "Saving date_to_load to ${LastDayFile}" echo ${date_to_load} > ${LastDayFile} fi \ No newline at end of file