From 10c7c0b5fdbbe41fcddd091caf8c9d3ed6b1ca4d Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 24 Jun 2011 15:13:47 -0400 Subject: [PATCH 1/3] CC-2419: Media monitor does not import files that already existed in /srv/airtime/stor -problem where media-monitor froze on startup if rabbitmq wasn't running is fixed (now consistent with pypo) --- .../airtimefilemonitor/airtimenotifier.py | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimenotifier.py b/python_apps/media-monitor/airtimefilemonitor/airtimenotifier.py index c8607b1a9..25053362d 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimenotifier.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimenotifier.py @@ -27,13 +27,26 @@ class AirtimeNotifier(Notifier): self.import_processes = {} self.watched_folders = [] - schedule_exchange = Exchange("airtime-media-monitor", "direct", durable=True, auto_delete=True) - schedule_queue = Queue("media-monitor", exchange=schedule_exchange, key="filesystem") - self.connection = BrokerConnection(self.config.cfg["rabbitmq_host"], self.config.cfg["rabbitmq_user"], self.config.cfg["rabbitmq_password"], "/") - channel = self.connection.channel() - consumer = Consumer(channel, schedule_queue) - consumer.register_callback(self.handle_message) - consumer.consume() + while not self.init_rabbit_mq(): + logger.error("Error connecting to RabbitMQ Server. Trying again in few seconds") + time.sleep(5) + + def init_rabbit_mq(self): + logger = logging.getLogger('fetch') + logger.info("Initializing RabbitMQ stuff") + try: + schedule_exchange = Exchange("airtime-media-monitor", "direct", durable=True, auto_delete=True) + schedule_queue = Queue("media-monitor", exchange=schedule_exchange, key="filesystem") + self.connection = BrokerConnection(self.config.cfg["rabbitmq_host"], self.config.cfg["rabbitmq_user"], self.config.cfg["rabbitmq_password"], "/") + channel = self.connection.channel() + consumer = Consumer(channel, schedule_queue) + consumer.register_callback(self.handle_message) + consumer.consume() + except Exception, e: + logger.error(e) + return False + + return True def handle_message(self, body, message): # ACK the message to take it off the queue From 21cf476bfb5ff92af76d18ca9c8aa2a262f7f143 Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 24 Jun 2011 16:01:40 -0400 Subject: [PATCH 2/3] cc-2444: audio preview is broken --- airtime_mvc/application/views/scripts/playlist/update.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/views/scripts/playlist/update.phtml b/airtime_mvc/application/views/scripts/playlist/update.phtml index 08085623f..a7cc9c5c9 100644 --- a/airtime_mvc/application/views/scripts/playlist/update.phtml +++ b/airtime_mvc/application/views/scripts/playlist/update.phtml @@ -5,7 +5,7 @@
  • ', + onclick="audioPreview('', 'spl_')">
    From 7607bce6c83308716ffe663ff55fe4d1f84aed42 Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 24 Jun 2011 16:04:57 -0400 Subject: [PATCH 3/3] CC-2403: Downloading a file via the web UI returns an absolute path, not relative -fixed to take into account the base URL. --- airtime_mvc/application/controllers/LibraryController.php | 4 +++- airtime_mvc/application/models/StoredFile.php | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index c474f6639..7de2dc274 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -55,6 +55,8 @@ class LibraryController extends Zend_Controller_Action $id = $this->_getParam('id'); $type = $this->_getParam('type'); + $request = $this->getRequest(); + $baseUrl = $request->getBaseUrl(); $params = '/format/json/id/#id#/type/#type#'; @@ -79,7 +81,7 @@ class LibraryController extends Zend_Controller_Action $file_id = $this->_getParam('id', null); $file = StoredFile::Recall($file_id); - $url = $file->getRelativeFileUrl().'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true'; + $url = $file->getRelativeFileUrl($baseUrl).'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true'; $menu[] = array('action' => array('type' => 'gourl', 'url' => $url), 'title' => 'Download'); diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 951591d47..a6f79b1c8 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -449,10 +449,9 @@ class StoredFile { * Sometimes we want a relative URL and not a full URL. See bug * http://dev.sourcefabric.org/browse/CC-2403 */ - public function getRelativeFileUrl() + public function getRelativeFileUrl($baseUrl) { - global $CC_CONFIG; - return "api/get-media/file/".$this->getGunId().".".$this->getFileExtension(); + return $baseUrl."/api/get-media/file/".$this->getGunId().".".$this->getFileExtension(); } public static function Insert($md=null)