From 81c9eacd00787907576c168e4215a0e6baeaf6a2 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 27 Jun 2012 16:29:33 -0400 Subject: [PATCH 1/5] CC-3892: Pypopush can be executed before Pypofile copying file -fixed --- python_apps/pypo/pypofetch.py | 5 +++-- python_apps/pypo/pypofile.py | 3 +++ python_apps/pypo/pypopush.py | 18 +++++++++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index 1dbe97070..de76a4ca0 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -171,8 +171,8 @@ class PypoFetch(Thread): self.logger.debug('Getting information needed on bootstrap from Airtime') info = self.api_client.get_bootstrap_info() if info == None: - self.logger.error('Unable to get bootstrap info.. Existing pypo...') - sys.exit(0) + self.logger.error('Unable to get bootstrap info.. Exiting pypo...') + sys.exit(1) else: self.logger.debug('info:%s', info) for k, v in info['switch_status'].iteritems(): @@ -427,6 +427,7 @@ class PypoFetch(Thread): fileExt = os.path.splitext(media_item['uri'])[1] dst = os.path.join(download_dir, media_item['id'] + fileExt) media_item['dst'] = dst + media_item['started_copying'] = False media_filtered[key] = media_item self.media_prepare_queue.put(copy.copy(media_filtered)) diff --git a/python_apps/pypo/pypofile.py b/python_apps/pypo/pypofile.py index 81a48b96d..6f9a213e6 100644 --- a/python_apps/pypo/pypofile.py +++ b/python_apps/pypo/pypofile.py @@ -70,6 +70,9 @@ class PypoFile(Thread): if do_copy: self.logger.debug("copying from %s to local cache %s" % (src, dst)) try: + + media_item['started_copying'] = True + """ copy will overwrite dst if it already exists """ diff --git a/python_apps/pypo/pypopush.py b/python_apps/pypo/pypopush.py index 9cac4022c..03420b9d9 100644 --- a/python_apps/pypo/pypopush.py +++ b/python_apps/pypo/pypopush.py @@ -80,8 +80,7 @@ class PypoPush(Thread): self.modify_cue_point(current_event_chain[0]) next_media_item_chain = current_event_chain time_until_next_play = 0 - #sleep for 0.2 seconds to give pypo-file time to copy. This is a quick - #fix that will be improved in 2.1.1 + #sleep for 0.2 seconds to give pypo-file time to copy. time.sleep(0.2) else: media_chain = filter(lambda item: (item["type"] == "file"), current_event_chain) @@ -313,7 +312,20 @@ class PypoPush(Thread): try: for media_item in event_chain: if media_item['type'] == "file": - self.telnet_to_liquidsoap(media_item) + + """ + Wait maximum 5 seconds (50 iterations) for file to become ready, otherwise + give up on it. + """ + iter_num = 0 + while not media_item['started_copying'] and iter_num < 50: + time.sleep(0.1) + iter_num += 1 + + if media_item['started_copying']: + self.telnet_to_liquidsoap(media_item) + else: + self.logger.warn("File %s did not become ready in less than 5 seconds. Skipping...", media_item['dst']) elif media_item['type'] == "event": if media_item['event_type'] == "kick_out": PypoFetch.disconnect_source(self.logger, self.telnet_lock, "live_dj") From 7f735fe2fa87acaa0c11000fdc1739773e752f51 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Thu, 28 Jun 2012 12:12:22 -0400 Subject: [PATCH 2/5] Log file cleanup + improvements -Don't show queue timeout as error -Show UTC time and current timezone on pypo startup --- python_apps/pypo/pypocli.py | 10 +++++++++- python_apps/pypo/pypofetch.py | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/python_apps/pypo/pypocli.py b/python_apps/pypo/pypocli.py index c2094003c..e11de3047 100644 --- a/python_apps/pypo/pypocli.py +++ b/python_apps/pypo/pypocli.py @@ -2,8 +2,10 @@ Python part of radio playout (pypo) """ -import time from optparse import OptionParser +from datetime import datetime + +import time import sys import signal import logging @@ -124,6 +126,12 @@ if __name__ == '__main__': logger.info('# Liquidsoap Scheduled Playout System #') logger.info('###########################################') + #Although all of our calculations are in UTC, it is useful to know what timezone + #the local machine is, so that we have a reference for what time the actual + #log entries were made + logger.info("Timezone: %s" % time.tzname) + logger.info("UTC time: %s" % datetime.utcnow()) + signal.signal(signal.SIGINT, keyboardInterruptHandler) # initialize diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index de76a4ca0..c62c6ca57 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -9,6 +9,8 @@ import telnetlib import copy from threading import Thread +from Queue import Empty + from api_clients import api_client from std_err_override import LogWriter @@ -493,6 +495,8 @@ class PypoFetch(Thread): message = self.fetch_queue.get(block=True, timeout=self.listener_timeout) self.handle_message(message) + except Empty, e: + self.logger.info("Queue timeout. Fetching schedule manually") except Exception, e: import traceback top = traceback.format_exc() From 63020cf2887ebe3e17059e24c7035d3d9c21d5dc Mon Sep 17 00:00:00 2001 From: James Date: Thu, 28 Jun 2012 12:25:15 -0400 Subject: [PATCH 3/5] CC-3955: System -> Preferences: Timezone setting is the first one in the list, not the current (local) timezone - adding some code to validate the timezone that is parsed --- install_minimal/include/AirtimeInstall.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install_minimal/include/AirtimeInstall.php b/install_minimal/include/AirtimeInstall.php index e656bf983..d0c2ed3f7 100644 --- a/install_minimal/include/AirtimeInstall.php +++ b/install_minimal/include/AirtimeInstall.php @@ -321,6 +321,10 @@ class AirtimeInstall $con = Propel::getConnection(); // we need to run php as commandline because we want to get the timezone in cli php.ini file $defaultTimezone = exec("php -r 'echo date_default_timezone_get().PHP_EOL;'"); + $defaultTimezone = trim($defaultTimezone); + if((!in_array($defaultTimezone, DateTimeZone::listIdentifiers()))){ + $defaultTimezone = "UTC"; + } $sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', '$defaultTimezone')"; $result = $con->exec($sql); if ($result < 1) { From d13ade977ab7332ce9e0860a307d92b5bb2bb876 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 28 Jun 2012 13:28:45 -0400 Subject: [PATCH 4/5] CC-4034: Files on Watched folder shouldn't be deleted physically. - fixed --- airtime_mvc/application/models/StoredFile.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index ccee5525c..a422b33f8 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -327,7 +327,10 @@ class Application_Model_StoredFile { throw new DeleteScheduledFileException(); } - if (file_exists($filepath)) { + $music_dir = Application_Model_MusicDir::getDirByPK($this->_file->getDbDirectory()); + $type = $music_dir->getType(); + + if (file_exists($filepath) && $type == "stor") { $data = array("filepath" => $filepath, "delete" => 1); Application_Model_RabbitMq::SendMessageToMediaMonitor("file_delete", $data); } From 6c83633933b591ab56dc17246033564b479ce1e7 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 28 Jun 2012 13:33:01 -0400 Subject: [PATCH 5/5] CC-4008: Inconsistent button labels for Play/Preview in Now Playing page - changed everyting to "Preview" --- airtime_mvc/application/controllers/LibraryController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index e3267cf09..99fdd923f 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -41,7 +41,7 @@ class LibraryController extends Zend_Controller_Action $user = new Application_Model_User($userInfo->id); //Open a jPlayer window and play the audio clip. - $menu["play"] = array("name"=> "Play", "icon" => "play"); + $menu["play"] = array("name"=> "Preview", "icon" => "play"); $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));