From cb9eb2f99340b9a8ad1607579a575862c2ceb752 Mon Sep 17 00:00:00 2001 From: Justin Emter Date: Wed, 28 Mar 2018 10:32:08 -0700 Subject: [PATCH] Removed daily sched update functionality from app. Added logic to generate_daily_sched.sh to startstop channel, update daily schedule. --- PseudoChannel.py | 14 ++++++++++---- generate_daily_sched.sh | 22 +++++++++++++++------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/PseudoChannel.py b/PseudoChannel.py index 67f951d..e3e67fc 100644 --- a/PseudoChannel.py +++ b/PseudoChannel.py @@ -373,8 +373,12 @@ class PseudoChannel(): def generate_daily_schedule(self): print("#### Generating Daily Schedule") - logging.info("##### Dropping previous daily_schedule database") - self.db.remove_all_daily_scheduled_items() + #logging.info("##### Dropping previous daily_schedule database") + #self.db.remove_all_daily_scheduled_items() + + self.db.drop_daily_schedule_table() + + self.db.create_daily_schedule_table() if self.USING_COMMERCIAL_INJECTION: self.commercials = PseudoChannelCommercial( @@ -1020,9 +1024,11 @@ if __name__ == '__main__': print("----- Recieved error when running generate_daily_schedule()") generate_memory_schedule(pseudo_channel.db.get_daily_schedule(), True) - schedule.every().day.at(daily_update_time).do( + """Commenting out below and leaving all updates to be handled by cron task""" + """schedule.every().day.at(daily_update_time).do( go_generate_daily_sched - ).tag('daily-update') + ).tag('daily-update')""" + sleep_before_triggering_play_now = 1 '''When the process is killed, stop any currently playing media & cleanup''' diff --git a/generate_daily_sched.sh b/generate_daily_sched.sh index 254a252..bd40e53 100755 --- a/generate_daily_sched.sh +++ b/generate_daily_sched.sh @@ -3,9 +3,10 @@ # file: generate_daily_sched.sh #---- -# This file is meant to be setup with a crontab task to generate daily schedule (if app isn't already running). -# You only need to use this script if using the "Power Saving / External Controller" options. -# If you plan on running PseudoChannel.py manually using the "-r" flag then you do not need to use this file (nor should you). +# This file is meant to be setup with a crontab task to generate daily schedule (even if app is already running). +# +# **This file is also used to startstop a running channel, trigger an update and restart the channel** +# # If planning on using the ./startstop.sh script to save power, etc. this script needs to be used to # update the daily schedule if the app is not running. #---- @@ -29,7 +30,7 @@ python_to_use="$(which python)" log_file=pseudo-channel.log -SCRIPT_PATH=$(dirname `which $0`) +SCRIPT_PATH=$(pwd) #----END EDITABLE VARS------- @@ -37,11 +38,18 @@ if [ ! -e $SCRIPT_PATH/$pid_file ]; then $python_to_use $SCRIPT_PATH/PseudoChannel.py -g >> $SCRIPT_PATH/$log_file - echo "+++++ PseudoChannel.py is not already running so I am generating the daily schedule." >> $SCRIPT_PATH/$log_file + echo "+++++ PseudoChannel.py is not already running am generating the daily schedule." >> $SCRIPT_PATH/$log_file else - - echo "+++++ PseudoChannel.py @: $the_pid is already running, sleeping instead." >> $SCRIPT_PATH/$log_file + echo "+++++ PseudoChannel.py @: $the_pid is already running, stopping channel and running daily schedule update." >> $SCRIPT_PATH/$log_file + + bash $SCRIPT_PATH/startstop.sh + + $python_to_use $SCRIPT_PATH/PseudoChannel.py -g >> $SCRIPT_PATH/$log_file + + bash $SCRIPT_PATH/startstop.sh + + echo "+++++ Successfully stopped running channel, generated daily schedule and restarted script." fi \ No newline at end of file