Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
James 2012-04-09 10:50:51 -04:00
commit 6785a373a1
9 changed files with 98 additions and 47 deletions

View file

@ -58,7 +58,8 @@ class ApiController extends Zend_Controller_Action
$this->_helper->viewRenderer->setNoRender(true);
$api_key = $this->_getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
@ -333,7 +334,8 @@ class ApiController extends Zend_Controller_Action
$api_key = $this->_getParam('api_key');
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
if(!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource. ';
@ -355,7 +357,8 @@ class ApiController extends Zend_Controller_Action
$this->_helper->viewRenderer->setNoRender(true);
$api_key = $this->_getParam('api_key');
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
if(!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
@ -378,7 +381,8 @@ class ApiController extends Zend_Controller_Action
global $CC_CONFIG;
$api_key = $this->_getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
@ -411,7 +415,8 @@ class ApiController extends Zend_Controller_Action
global $CC_CONFIG;
$api_key = $this->_getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
@ -435,7 +440,8 @@ class ApiController extends Zend_Controller_Action
global $CC_CONFIG;
$api_key = $this->_getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
@ -542,7 +548,8 @@ class ApiController extends Zend_Controller_Action
$this->_helper->viewRenderer->setNoRender(true);
$api_key = $this->_getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
@ -564,7 +571,8 @@ class ApiController extends Zend_Controller_Action
$request = $this->getRequest();
$api_key = $request->getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
@ -667,7 +675,8 @@ class ApiController extends Zend_Controller_Action
$request = $this->getRequest();
$api_key = $request->getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
@ -683,7 +692,8 @@ class ApiController extends Zend_Controller_Action
$request = $this->getRequest();
$api_key = $request->getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
@ -711,7 +721,8 @@ class ApiController extends Zend_Controller_Action
$api_key = $request->getParam('api_key');
$path = base64_decode($request->getParam('path'));
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
@ -728,7 +739,8 @@ class ApiController extends Zend_Controller_Action
$api_key = $request->getParam('api_key');
$path = base64_decode($request->getParam('path'));
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
@ -745,7 +757,8 @@ class ApiController extends Zend_Controller_Action
$api_key = $request->getParam('api_key');
$path = base64_decode($request->getParam('path'));
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
@ -760,7 +773,8 @@ class ApiController extends Zend_Controller_Action
$request = $this->getRequest();
$api_key = $request->getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
@ -777,14 +791,13 @@ class ApiController extends Zend_Controller_Action
$request = $this->getRequest();
$api_key = $request->getParam('api_key');
$getDiskInfo = $request->getParam('diskinfo') == "true";
/*
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
exit;
}
*/
$status = array(
"platform"=>Application_Model_Systemstatus::GetPlatformInfo(),
@ -846,7 +859,8 @@ class ApiController extends Zend_Controller_Action
$request = $this->getRequest();
$api_key = $request->getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
@ -926,7 +940,8 @@ class ApiController extends Zend_Controller_Action
$request = $this->getRequest();
$api_key = $request->getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
@ -945,7 +960,8 @@ class ApiController extends Zend_Controller_Action
$request = $this->getRequest();
$api_key = $request->getParam('api_key');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';
@ -979,7 +995,8 @@ class ApiController extends Zend_Controller_Action
$password = $request->getParam('password');
$djtype = $request->getParam('djtype');
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
if (!in_array($api_key, $CC_CONFIG["apiKey"]) &&
is_null(Zend_Auth::getInstance()->getStorage()->read()))
{
header('HTTP/1.0 401 Unauthorized');
print 'You are not allowed to access this resource.';

View file

@ -431,6 +431,7 @@ class ScheduleController extends Zend_Controller_Action
$this->view->percentFilled = $show->getPercentScheduled();
$this->view->showContent = $show->getShowListContent();
$this->view->dialog = $this->view->render('schedule/show-content-dialog.phtml');
$this->view->showTitle = $show->getName();
unset($this->view->showContent);
}

View file

@ -176,7 +176,7 @@ function buildContentDialog (json){
dialog.dialog({
autoOpen: false,
title: 'Show Contents',
title: "Contents of Show \"" + json.showTitle + "\"",
width: width,
height: height,
modal: true,
@ -422,4 +422,4 @@ $(document).ready(function() {
};
}
});
});
});

View file

@ -5,4 +5,14 @@
class AirtimeMiscUpgrade{
public static function start(){
}
public static function adjustMonitCfgPermissions(){
/* Make the read permission of Monit cfg files more strict */
chmod("/etc/monit/conf.d/monit-airtime-generic.cfg", 0600);
chmod("/etc/monit/conf.d/monit-airtime-liquidsoap.cfg", 0600);
chmod("/etc/monit/conf.d/monit-airtime-media-monitor.cfg", 0600);
chmod("/etc/monit/conf.d/monit-airtime-playout.cfg", 0600);
chmod("/etc/monit/conf.d/monit-airtime-rabbitmq-server.cfg", 0600);
}
}

View file

@ -135,18 +135,17 @@ class AirtimeMediaMonitorBootstrap():
for file_path in deleted_files_set:
self.logger.debug("deleted file")
full_file_path = "%s%s" % (dir, file_path)
full_file_path = os.path.join(dir, file_path)
self.logger.debug(full_file_path)
self.pe.handle_removed_file(False, full_file_path)
for file_path in new_files_set:
self.logger.debug("new file")
full_file_path = "%s%s" % (dir, file_path)
full_file_path = os.path.join(dir, file_path)
self.logger.debug(full_file_path)
if os.path.exists(full_file_path):
organized_filepath = self.pe.handle_created_file(False, full_file_path, os.path.basename(full_file_path))
if organized_filepath is not None:
self.pe.handle_created_file(False, organized_filepath, os.path.basename(organized_filepath))
self.pe.handle_created_file(False, full_file_path, os.path.basename(full_file_path))
for file_path in modified_files_set:
self.logger.debug("modified file")

View file

@ -137,15 +137,12 @@ class AirtimeProcessEvent(ProcessEvent):
if self.mmc.is_parent_directory(pathname, self.config.organize_directory):
#file was created in /srv/airtime/stor/organize. Need to process and move
#to /srv/airtime/stor/imported
new_filepath = self.mmc.organize_new_file(pathname)
return new_filepath
else:
self.mmc.set_needed_file_permissions(pathname, dir)
if self.mmc.is_parent_directory(pathname, self.config.recorded_directory):
is_recorded = True
else :
is_recorded = False
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': pathname, 'is_recorded_show': is_recorded})
pathname = self.mmc.organize_new_file(pathname)
name = os.path.basename(pathname)
self.mmc.set_needed_file_permissions(pathname, dir)
is_recorded = self.mmc.is_parent_directory(pathname, self.config.recorded_directory)
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': pathname, 'is_recorded_show': is_recorded})
else:
#event is because of a created directory

View file

@ -3,6 +3,7 @@ import grp
import pwd
import logging
import stat
import subprocess
from subprocess import Popen, PIPE
from airtimemetadata import AirtimeMetadata
@ -289,3 +290,16 @@ class MediaMonitorCommon:
self.logger.warn("File %s, has invalid metadata", pathname)
return filepath
def test_file_playability(pathname):
"""
Test if the file can be played by Liquidsoap. Return "True" if Liquidsoap
can play it, or if Liquidsoap is not found.
"""
liquidsoap_found = subprocess.call("which liquidsoap", shell=True)
if liquidsoap_found == 0:
return_code = subprocess.call("liquidsoap -c 'output.dummy(single(\"%s\"))'" % pathname, shell=True)
else:
return_code = 0
return (return_code == 0)

View file

@ -1,12 +1,20 @@
from mediaconfig import AirtimeMediaConfig
import mediamonitorcommon
class MediaMonitorWorkerProcess:
#this function is run in its own process, and continuously
#checks the queue for any new file events.
def process_file_events(self, queue, notifier):
while True:
event = queue.get()
notifier.logger.info("received event %s", event)
notifier.update_airtime(event)
try:
event = queue.get()
if event['mode'] == AirtimeMediaConfig.MODE_CREATE:
filepath = event['filepath']
if mediamonitorcommon.test_file_playability(filepath):
notifier.logger.info("received event %s", event)
notifier.update_airtime(event)
else:
notifier.logger.warn("Liquidsoap integrity check for file at %s failed. Not adding to media library.", filepath)
except Exception, e:
notifier.logger.error(e)

View file

@ -183,9 +183,14 @@ class PypoPush(Thread):
problem_at_iteration = None
for queue_item in liquidsoap_queue_approx:
if queue_item['start'] in media_schedule.keys():
if queue_item['id'] == media_schedule[queue_item['start']]['id']:
#Everything OK for this iteration.
pass
media_item = media_schedule[queue_item['start']]
if queue_item['id'] == media_item['id']:
if queue_item['end'] == media_item['end']:
#Everything OK for this iteration.
pass
else:
problem_at_iteration = iteration
break
else:
#A different item has been scheduled at the same time! Need to remove
#all tracks from the Liquidsoap queue starting at this point, and re-add
@ -204,7 +209,7 @@ class PypoPush(Thread):
#The first item in the Liquidsoap queue (the one that is currently playing)
#has changed or been removed from the schedule. We need to clear the entire
#queue, and push the new schedule
self.logger.debug("Problem at iteration %s", problem_at_iteration)
self.logger.debug("Change in link %s of current chain", problem_at_iteration)
self.remove_from_liquidsoap_queue(problem_at_iteration, liquidsoap_queue_approx)
return problem_at_iteration