From 25ab4d39b21178bc701434941314eedd4445c531 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 31 Jan 2012 11:22:30 -0500 Subject: [PATCH 01/10] CC-3286: Shows not recorded after upgrade to 2.0.0 from 1.8.2 - The issue was that the recorder wasn't pulling any schedule from Airtime. It should pull it when real timeout(every 1 hr) happens --- python_apps/show-recorder/recorder.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/python_apps/show-recorder/recorder.py b/python_apps/show-recorder/recorder.py index 80bc4ada8..1cd4425a1 100644 --- a/python_apps/show-recorder/recorder.py +++ b/python_apps/show-recorder/recorder.py @@ -180,6 +180,7 @@ class CommandListener(): self.current_schedule = {} self.shows_to_record = {} self.time_till_next_show = 3600 + self.real_timeout = True self.logger.info("RecorderFetch: init complete") self.server_timezone = ''; @@ -240,11 +241,13 @@ class CommandListener(): next_show = getDateTimeObj(start_time) delta = next_show - tnow + self.real_timeout = False out = delta.seconds self.logger.debug("Next show %s", next_show) self.logger.debug("Now %s", tnow) else: + self.real_timeout = True out = 3600 return out @@ -306,6 +309,8 @@ class CommandListener(): self.logger.error(e) loops = 1 + recording = False + while True: self.logger.info("Loop #%s", loops) try: @@ -315,10 +320,19 @@ class CommandListener(): self.logger.info(s) # start recording self.start_record() + + # if real timeout happended get show schedule from airtime + if self.real_timeout : + temp = self.api_client.get_shows_to_record() + if temp is not None: + shows = temp['shows'] + self.server_timezone = temp['server_timezone'] + self.parse_shows(shows) + self.logger.info("Real Timeout: the schedule has updated") + except Exception, e: self.logger.info(e) time.sleep(3) - loops += 1 if __name__ == '__main__': From 1df1388602d1d23edc1c3516498a719f2e5f631c Mon Sep 17 00:00:00 2001 From: James Date: Tue, 31 Jan 2012 11:37:12 -0500 Subject: [PATCH 02/10] CC-3286: Shows not recorded after upgrade to 2.0.0 from 1.8.2 - bug fix --- python_apps/show-recorder/recorder.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python_apps/show-recorder/recorder.py b/python_apps/show-recorder/recorder.py index 1cd4425a1..7ac18b046 100644 --- a/python_apps/show-recorder/recorder.py +++ b/python_apps/show-recorder/recorder.py @@ -275,8 +275,9 @@ class CommandListener(): self.sr.start() #remove show from shows to record. del self.shows_to_record[start_time] - time_till_next_show = self.get_time_till_next_show() - self.time_till_next_show = time_till_next_show + self.time_till_next_show = self.get_time_till_next_show() + # set real_timtout to false no matter what + self.real_timeout = False except Exception,e : import traceback top = traceback.format_exc() From 6812f69962070e008312dd309f509b07c0b7f218 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 31 Jan 2012 15:28:57 -0500 Subject: [PATCH 03/10] CC-3286: Shows not recorded after upgrade to 2.0.0 from 1.8.2 - fixed a bug. - extra fix: handle cancel recording event gracefully - better log --- python_apps/show-recorder/recorder.cfg | 1 + python_apps/show-recorder/recorder.py | 27 +++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/python_apps/show-recorder/recorder.cfg b/python_apps/show-recorder/recorder.cfg index c010a8645..d817a32b2 100644 --- a/python_apps/show-recorder/recorder.cfg +++ b/python_apps/show-recorder/recorder.cfg @@ -24,6 +24,7 @@ record_bitrate = 256 record_samplerate = 44100 record_channels = 2 record_sample_size = 16 +record_timeout = 3600 #can be either ogg|mp3, mp3 recording requires installation of the package "lame" record_file_type = 'ogg' diff --git a/python_apps/show-recorder/recorder.py b/python_apps/show-recorder/recorder.py index 7ac18b046..3ec1caf39 100644 --- a/python_apps/show-recorder/recorder.py +++ b/python_apps/show-recorder/recorder.py @@ -179,8 +179,7 @@ class CommandListener(): self.sr = None self.current_schedule = {} self.shows_to_record = {} - self.time_till_next_show = 3600 - self.real_timeout = True + self.time_till_next_show = config["record_timeout"] self.logger.info("RecorderFetch: init complete") self.server_timezone = ''; @@ -214,7 +213,7 @@ class CommandListener(): self.parse_shows(temp) self.server_timezone = m['server_timezone'] elif(command == 'cancel_recording'): - if self.sr.is_recording(): + if self.sr is not None and self.sr.is_recording(): self.sr.cancel_recording() def parse_shows(self, shows): @@ -241,14 +240,12 @@ class CommandListener(): next_show = getDateTimeObj(start_time) delta = next_show - tnow - self.real_timeout = False out = delta.seconds self.logger.debug("Next show %s", next_show) self.logger.debug("Now %s", tnow) else: - self.real_timeout = True - out = 3600 + out = config["record_timeout"] return out def start_record(self): @@ -276,8 +273,6 @@ class CommandListener(): #remove show from shows to record. del self.shows_to_record[start_time] self.time_till_next_show = self.get_time_till_next_show() - # set real_timtout to false no matter what - self.real_timeout = False except Exception,e : import traceback top = traceback.format_exc() @@ -316,14 +311,21 @@ class CommandListener(): self.logger.info("Loop #%s", loops) try: # block until 5 seconds before the next show start - self.connection.drain_events(timeout=self.time_till_next_show) + self.connection.drain_events(timeout=int(self.time_till_next_show)) except socket.timeout, s: self.logger.info(s) + + # start_record set time_till_next_show to config["record_timeout"] so we should check before + # if timeout amount was 1 hr.. + update_schedule = False + if int(self.time_till_next_show) == int(config["record_timeout"]) : + update_schedule = True + # start recording self.start_record() # if real timeout happended get show schedule from airtime - if self.real_timeout : + if update_schedule : temp = self.api_client.get_shows_to_record() if temp is not None: shows = temp['shows'] @@ -332,7 +334,10 @@ class CommandListener(): self.logger.info("Real Timeout: the schedule has updated") except Exception, e: - self.logger.info(e) + import traceback + top = traceback.format_exc() + self.logger.error('Exception: %s', e) + self.logger.error("traceback: %s", top) time.sleep(3) loops += 1 From d495eac3268ae4a1c1989b543227376183a2786d Mon Sep 17 00:00:00 2001 From: Daniel Franklin Date: Tue, 31 Jan 2012 14:54:03 -0500 Subject: [PATCH 04/10] CC-3230: Show appropriate error message if disk is full when attempting to upload files via the web UI -fixed using the return result of the rename call to verifty the upload worked. --- airtime_mvc/application/models/StoredFile.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index d371d083f..9d445fa0f 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -904,10 +904,16 @@ class Application_Model_StoredFile { $audio_stor = $stor . DIRECTORY_SEPARATOR . $fileName; Logging::log("copyFileToStor: moving file $audio_file to $audio_stor"); - //Martin K.: changed to rename: Much less load + quicker since this is an atomic operation + $r = @rename($audio_file, $audio_stor); - + + if ($r === false) { + #something went wrong likely there wasn't enough space in the audio_stor to move the file too. + #warn the user that the file wasn't uploaded and they should check if there is enough disk space. + die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "File was not uploaded, this error will occur if the computer hard drive does not have enough disk space."}}'); + } + //$r = @copy($audio_file, $audio_stor); //$r = @unlink($audio_file); } From 5d02581d38f4591c9c798da4818c96a134edf98f Mon Sep 17 00:00:00 2001 From: Daniel Franklin Date: Tue, 31 Jan 2012 15:17:53 -0500 Subject: [PATCH 05/10] CC-3230: Show appropriate error message if disk is full when attempting to upload files via the web UI Modified the error message to prepend a The, simple change. --- airtime_mvc/application/models/StoredFile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 9d445fa0f..d99058fa4 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -911,7 +911,7 @@ class Application_Model_StoredFile { if ($r === false) { #something went wrong likely there wasn't enough space in the audio_stor to move the file too. #warn the user that the file wasn't uploaded and they should check if there is enough disk space. - die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "File was not uploaded, this error will occur if the computer hard drive does not have enough disk space."}}'); + die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "The file was not uploaded, this error will occur if the computer hard drive does not have enough disk space."}}'); } //$r = @copy($audio_file, $audio_stor); From 4ffe79a2869aaf67fedce12a1eb91ddd16094d6b Mon Sep 17 00:00:00 2001 From: James Date: Tue, 31 Jan 2012 16:12:11 -0500 Subject: [PATCH 06/10] CC-3290: A file should be removed from playlists if it is removed through the interface - fixed --- airtime_mvc/application/controllers/LibraryController.php | 2 +- airtime_mvc/application/models/StoredFile.php | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index d74104cd2..1068c403f 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -168,7 +168,7 @@ class LibraryController extends Zend_Controller_Action return; } - $res = $file->delete(); + $res = $file->delete(true); if (PEAR::isError($res)) { $this->view->message = $res->getMessage(); diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index d99058fa4..c51ea3dfd 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -303,7 +303,7 @@ class Application_Model_StoredFile { * * @return void|PEAR_Error */ - public function delete() + public function delete($deleteFromPlaylist=false) { if ($this->exists()) { if ($this->getFormat() == 'audioclip') { @@ -314,8 +314,9 @@ class Application_Model_StoredFile { } } - // don't delete from the playslist. We might want to put a flag - //Application_Model_Playlist::DeleteFileFromAllPlaylists($this->getId()); + if($deleteFromPlaylist){ + Application_Model_Playlist::DeleteFileFromAllPlaylists($this->getId()); + } // set file_exists falg to false $this->_file->setDbFileExists(false); From 3643c9caafb994f4ddbf194fa3d940fcc16d82e8 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 1 Feb 2012 10:57:38 -0500 Subject: [PATCH 07/10] SAAS-174: Ability to add Google Analytics to the demo instance - done --- airtime_mvc/application/Bootstrap.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index 64223f823..852078675 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -62,6 +62,8 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap protected function _initHeadScript() { + global $CC_CONFIG; + $view = $this->getResource('view'); $baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl(); $baseDir = dirname($_SERVER['SCRIPT_FILENAME']); @@ -86,6 +88,9 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap $view->headScript()->appendScript("var livechat_client_id = '$client_id';"); $view->headScript()->appendFile($baseUrl . '/js/airtime/common/livechat.js?'.filemtime($baseDir.'/js/airtime/common/livechat.js'), 'text/javascript'); } + if(isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1){ + $view->headScript()->appendFile($baseUrl.'/js/libs/google-analytics.js?'.filemtime($baseDir.'/js/libs/google-analytics.js'),'text/javascript'); + } } protected function _initViewHelpers() From 80d99f013a3aec3efb8583052d158aae106c76f2 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 1 Feb 2012 11:48:29 -0500 Subject: [PATCH 08/10] SAAS-174: Ability to add Google Analytics to the demo instance - adding google-analytics.js --- airtime_mvc/public/js/libs/google-analytics.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 airtime_mvc/public/js/libs/google-analytics.js diff --git a/airtime_mvc/public/js/libs/google-analytics.js b/airtime_mvc/public/js/libs/google-analytics.js new file mode 100644 index 000000000..5a9352270 --- /dev/null +++ b/airtime_mvc/public/js/libs/google-analytics.js @@ -0,0 +1,9 @@ +var _gaq = _gaq || []; +_gaq.push(['_setAccount', 'UA-28765064-1']); +_gaq.push(['_trackPageview']); + +(function() { + var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); +})(); From df73726961fe796903a0b4d7511126d5897fde82 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 1 Feb 2012 12:09:59 -0500 Subject: [PATCH 09/10] CC-3293: Stream settings page does not remember the stream metadata format - fixed --- airtime_mvc/application/controllers/PreferenceController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 62b9343b4..2053a947e 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -205,6 +205,7 @@ class PreferenceController extends Zend_Controller_Action $values['icecast_vorbis_metadata'] = $form->getValue('icecast_vorbis_metadata'); $values['output_sound_device_type'] = $form->getValue('output_sound_device_type'); + $values['streamFormat'] = $form->getValue('streamFormat'); } if(!$error){ @@ -214,6 +215,8 @@ class PreferenceController extends Zend_Controller_Action for($i=1;$i<=$num_of_stream;$i++){ Application_Model_StreamSetting::setLiquidsoapError($i, "waiting"); } + // this goes into cc_pref table + Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']); // store stream update timestamp Application_Model_Preference::SetStreamUpdateTimestamp(); Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data); From 3b9bc723ab7e080eade873ddef55e843059d5273 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 1 Feb 2012 14:52:17 -0500 Subject: [PATCH 10/10] CC-3286: Shows not recorded after upgrade to 2.0.0 from 1.8.2 - missing a line from cfg in upgrade folder --- install_minimal/upgrades/airtime-2.0.0/recorder.cfg.200 | 1 + 1 file changed, 1 insertion(+) diff --git a/install_minimal/upgrades/airtime-2.0.0/recorder.cfg.200 b/install_minimal/upgrades/airtime-2.0.0/recorder.cfg.200 index 2765f9781..9ac92ce44 100644 --- a/install_minimal/upgrades/airtime-2.0.0/recorder.cfg.200 +++ b/install_minimal/upgrades/airtime-2.0.0/recorder.cfg.200 @@ -24,6 +24,7 @@ record_bitrate = 256 record_samplerate = 44100 record_channels = 2 record_sample_size = 16 +record_timeout = 3600 #can be either ogg|mp3, mp3 recording requires installation of the package "lame" record_file_type = 'ogg' \ No newline at end of file