From c5f3e40397b0933232b5fda2b9e4c1642657f17f Mon Sep 17 00:00:00 2001 From: James Date: Mon, 30 Jan 2012 16:28:27 -0500 Subject: [PATCH 1/7] SAAS-174: Ability to add Google Analytics to the demo instance - done --- airtime_mvc/application/Bootstrap.php | 19 +++++++++++++++++++ .../application/layouts/scripts/bare.phtml | 1 + .../application/layouts/scripts/layout.phtml | 1 + .../application/layouts/scripts/library.phtml | 1 + .../application/layouts/scripts/login.phtml | 1 + .../application/layouts/scripts/search.phtml | 1 + 6 files changed, 24 insertions(+) diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index 09433a9c8..69269b3b4 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,23 @@ 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){ + // since we need to append google analytic code right before we can't use appendFile function + // we will just store raw html into some variable + $view->google_analytics = ""; + } } protected function _initViewHelpers() diff --git a/airtime_mvc/application/layouts/scripts/bare.phtml b/airtime_mvc/application/layouts/scripts/bare.phtml index 43c42463c..b89443505 100644 --- a/airtime_mvc/application/layouts/scripts/bare.phtml +++ b/airtime_mvc/application/layouts/scripts/bare.phtml @@ -5,6 +5,7 @@ Live stream headScript() ?> headLink() ?> + google_analytics)?$this->google_analytics:"" ?>
layout()->content ?>
diff --git a/airtime_mvc/application/layouts/scripts/layout.phtml b/airtime_mvc/application/layouts/scripts/layout.phtml index 53ff557d1..10e6a5ec9 100644 --- a/airtime_mvc/application/layouts/scripts/layout.phtml +++ b/airtime_mvc/application/layouts/scripts/layout.phtml @@ -5,6 +5,7 @@ headTitle() ?> headScript() ?> headLink() ?> + google_analytics)?$this->google_analytics:"" ?> diff --git a/airtime_mvc/application/layouts/scripts/library.phtml b/airtime_mvc/application/layouts/scripts/library.phtml index 1241dfb50..b2982c1f4 100644 --- a/airtime_mvc/application/layouts/scripts/library.phtml +++ b/airtime_mvc/application/layouts/scripts/library.phtml @@ -5,6 +5,7 @@ headTitle() ?> headScript() ?> headLink() ?> + google_analytics)?$this->google_analytics:"" ?> diff --git a/airtime_mvc/application/layouts/scripts/login.phtml b/airtime_mvc/application/layouts/scripts/login.phtml index 88328f2c5..e91b735ee 100644 --- a/airtime_mvc/application/layouts/scripts/login.phtml +++ b/airtime_mvc/application/layouts/scripts/login.phtml @@ -5,6 +5,7 @@ headTitle() ?> headScript() ?> headLink() ?> + google_analytics)?$this->google_analytics:"" ?> diff --git a/airtime_mvc/application/layouts/scripts/search.phtml b/airtime_mvc/application/layouts/scripts/search.phtml index 8cedbe21b..c3195b101 100644 --- a/airtime_mvc/application/layouts/scripts/search.phtml +++ b/airtime_mvc/application/layouts/scripts/search.phtml @@ -5,6 +5,7 @@ headTitle() ?> headScript() ?> headLink() ?> + google_analytics)?$this->google_analytics:"" ?>
partial('partialviews/header.phtml', array("user" => $this->loggedInAs())) ?>
From 733b23e7fc94bab39590f0c37e7c7ebfe96876fb Mon Sep 17 00:00:00 2001 From: James Date: Tue, 31 Jan 2012 11:22:30 -0500 Subject: [PATCH 2/7] 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 4874eb4f34801c5e08cead5c28564cb3529b51bc Mon Sep 17 00:00:00 2001 From: James Date: Tue, 31 Jan 2012 11:37:12 -0500 Subject: [PATCH 3/7] 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 3b64da7f4ebd2313fe085aa37b16bb314f1f4e04 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 31 Jan 2012 15:28:57 -0500 Subject: [PATCH 4/7] 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 7ee17ba07eb5a2b60f100ef9bb3234e0e5ad1860 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 31 Jan 2012 21:24:01 -0500 Subject: [PATCH 5/7] CC-3291: Airtime is missing Australia and Arctic timezones -fixed --- airtime_mvc/application/forms/GeneralPreferences.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/airtime_mvc/application/forms/GeneralPreferences.php b/airtime_mvc/application/forms/GeneralPreferences.php index 1514e1460..7bbb1784f 100644 --- a/airtime_mvc/application/forms/GeneralPreferences.php +++ b/airtime_mvc/application/forms/GeneralPreferences.php @@ -71,8 +71,10 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm 'Africa' => DateTimeZone::AFRICA, 'America' => DateTimeZone::AMERICA, 'Antarctica' => DateTimeZone::ANTARCTICA, + 'Arctic' => DateTimeZone::ARCTIC, 'Asia' => DateTimeZone::ASIA, 'Atlantic' => DateTimeZone::ATLANTIC, + 'Australia' => DateTimeZone::AUSTRALIA, 'Europe' => DateTimeZone::EUROPE, 'Indian' => DateTimeZone::INDIAN, 'Pacific' => DateTimeZone::PACIFIC From 11e0f3ead809ec0b083e2bc775b3ad8213270b80 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Thu, 2 Feb 2012 14:11:03 -0500 Subject: [PATCH 6/7] CC-3296: Sometimes the Current Playing Item on the top Panel in the UI incorrectly shows "Nothing Scheduled" --- airtime_mvc/application/models/ShowInstance.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index b5dbfb55b..7a70f73e2 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -784,6 +784,7 @@ class Application_Model_ShowInstance { $sql = "SELECT si.id" ." FROM $CC_CONFIG[showInstances] si" ." WHERE si.ends < TIMESTAMP '$p_timeNow'" + ." AND si.modified_instance = 'f'" ." ORDER BY si.ends DESC" ." LIMIT 1"; @@ -798,10 +799,18 @@ class Application_Model_ShowInstance { public static function GetCurrentShowInstance($p_timeNow){ global $CC_CONFIG, $CC_DBC; + /* Orderby si.starts descending, because in some cases + * we can have multiple shows overlapping each other. In + * this case, the show that started later is the one that + * is actually playing, and so this is the one we want. + */ + $sql = "SELECT si.id" ." FROM $CC_CONFIG[showInstances] si" ." WHERE si.starts <= TIMESTAMP '$p_timeNow'" ." AND si.ends > TIMESTAMP '$p_timeNow'" + ." AND si.modified_instance = 'f'" + ." ORDER BY si.starts DESC" ." LIMIT 1"; $id = $CC_DBC->GetOne($sql); @@ -818,6 +827,7 @@ class Application_Model_ShowInstance { $sql = "SELECT si.id" ." FROM $CC_CONFIG[showInstances] si" ." WHERE si.starts > TIMESTAMP '$p_timeNow'" + ." AND si.modified_instance = 'f'" ." ORDER BY si.starts" ." LIMIT 1"; From 214c6e85ccb6178e3044d126cd6b6e387f6a0d48 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Thu, 2 Feb 2012 16:14:13 -0500 Subject: [PATCH 7/7] -remove unneeded check of "if file_info is not None:" -remove undefined variable fomr phone_home_stat.php --- .../airtimefilemonitor/airtimemetadata.py | 30 ++++++++++--------- utils/phone_home_stat.php | 4 +-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py b/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py index 17c97259e..dd9b481af 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py @@ -161,22 +161,24 @@ class AirtimeMetadata: self.logger.error("Exception %s", e) return None + #check if file has any metadata if file_info is None: return None - #check if file has any metadata - if file_info is not None: - for key in file_info.keys() : - if key in self.mutagen2airtime and len(file_info[key]) > 0: - info = file_info[key][0] - while True: - temp = re.search(u"[\x80-\x9f]", info) - if temp is not None: - s = temp.group(0) - replace = self.cp1252toUnicode.get(s) - info = re.sub(s, replace, info) - else: - break - md[self.mutagen2airtime[key]] = info + + for key in file_info.keys() : + if key in self.mutagen2airtime and len(file_info[key]) > 0: + info = file_info[key][0] + while True: + temp = re.search(u"[\x80-\x9f]", info) + if temp is not None: + s = temp.group(0) + replace = self.cp1252toUnicode.get(s) + info = re.sub(s, replace, info) + else: + break + md[self.mutagen2airtime[key]] = info + + if 'MDATA_KEY_TITLE' not in md: #get rid of file extention from original name, name might have more than 1 '.' in it. #filepath = to_unicode(filepath) diff --git a/utils/phone_home_stat.php b/utils/phone_home_stat.php index c7738a6b4..fa6848bea 100644 --- a/utils/phone_home_stat.php +++ b/utils/phone_home_stat.php @@ -48,9 +48,7 @@ if (PEAR::isError($CC_DBC)) { echo "Database connection problem.".PHP_EOL; echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists". " with corresponding permissions.".PHP_EOL;*/ - if ($p_exitOnError) { - exit(1); - } + exit(1); } else { //echo "* Connected to database".PHP_EOL; $CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);