Merge branch '1.9.1' into devel
Conflicts: airtime_mvc/application/controllers/ApiController.php airtime_mvc/application/models/MusicDir.php python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py
This commit is contained in:
commit
5190a0c24c
|
@ -122,6 +122,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
$file_base_name = substr($file_base_name, 1);
|
$file_base_name = substr($file_base_name, 1);
|
||||||
header('Content-Disposition: attachment; filename="'.$file_base_name.'"');
|
header('Content-Disposition: attachment; filename="'.$file_base_name.'"');
|
||||||
}
|
}
|
||||||
|
$logger->info("Sending $filepath");
|
||||||
header("Content-Length: " . filesize($filepath));
|
header("Content-Length: " . filesize($filepath));
|
||||||
|
|
||||||
// !! binary mode !!
|
// !! binary mode !!
|
||||||
|
@ -539,6 +540,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||||
$filepath = str_replace("\\", "", $filepath);
|
$filepath = str_replace("\\", "", $filepath);
|
||||||
$files = Application_Model_StoredFile::RecallByPartialFilepath($filepath);
|
$files = Application_Model_StoredFile::RecallByPartialFilepath($filepath);
|
||||||
|
|
||||||
foreach($files as $file){
|
foreach($files as $file){
|
||||||
$file->delete();
|
$file->delete();
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,6 +281,7 @@ class Application_Model_MusicDir {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function removeWatchedDir($p_dir){
|
public static function removeWatchedDir($p_dir){
|
||||||
|
|
||||||
$real_path = realpath($p_dir)."/";
|
$real_path = realpath($p_dir)."/";
|
||||||
if($real_path != "/"){
|
if($real_path != "/"){
|
||||||
$p_dir = $real_path;
|
$p_dir = $real_path;
|
||||||
|
|
|
@ -598,6 +598,27 @@ class Application_Model_StoredFile {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function RecallByPartialFilepath($partial_path){
|
||||||
|
$path_info = MusicDir::splitFilePath($partial_path);
|
||||||
|
|
||||||
|
if (is_null($path_info)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$music_dir = MusicDir::getDirByPath($path_info[0]);
|
||||||
|
|
||||||
|
$files = CcFilesQuery::create()
|
||||||
|
->filterByDbDirectory($music_dir->getId())
|
||||||
|
->filterByDbFilepath("$path_info[1]%")
|
||||||
|
->find();
|
||||||
|
$res = array();
|
||||||
|
foreach ($files as $file){
|
||||||
|
$storedFile = new StoredFile();
|
||||||
|
$storedFile->_file = $file;
|
||||||
|
$res[] = $storedFile;
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
public static function searchFilesForPlaylistBuilder($datatables) {
|
public static function searchFilesForPlaylistBuilder($datatables) {
|
||||||
global $CC_CONFIG;
|
global $CC_CONFIG;
|
||||||
|
|
||||||
|
@ -751,7 +772,7 @@ class Application_Model_StoredFile {
|
||||||
$chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0;
|
$chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0;
|
||||||
$chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0;
|
$chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0;
|
||||||
$fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
|
$fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
|
||||||
Logging::log(__FILE__.':uploadFile(): filename='.$fileName);
|
Logging::log(__FILE__.":uploadFile(): filename=$fileName to $p_targetDir");
|
||||||
// Clean the fileName for security reasons
|
// Clean the fileName for security reasons
|
||||||
//this needs fixing for songs not in ascii.
|
//this needs fixing for songs not in ascii.
|
||||||
//$fileName = preg_replace('/[^\w\._]+/', '', $fileName);
|
//$fileName = preg_replace('/[^\w\._]+/', '', $fileName);
|
||||||
|
|
|
@ -677,7 +677,10 @@ class Airtime190Upgrade{
|
||||||
->findOne();
|
->findOne();
|
||||||
|
|
||||||
/* Handle Database Changes. */
|
/* Handle Database Changes. */
|
||||||
$stor_dir = realpath($values['general']['base_files_dir']."/stor")."/";
|
|
||||||
|
$pi = pathinfo($values['general']['base_files_dir']);
|
||||||
|
$stor_dir = $pi["dirname"].DIRECTORY_SEPARATOR.$pi["basename"].DIRECTORY_SEPARATOR."stor".DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
echo "* Inserting stor directory location $stor_dir into music_dirs table".PHP_EOL;
|
echo "* Inserting stor directory location $stor_dir into music_dirs table".PHP_EOL;
|
||||||
$propel_stor_dir->setDirectory($stor_dir);
|
$propel_stor_dir->setDirectory($stor_dir);
|
||||||
$propel_stor_dir->save();
|
$propel_stor_dir->save();
|
||||||
|
@ -763,6 +766,7 @@ exec("svc -dx /etc/service/pypo-liquidsoap/log");
|
||||||
exec("svc -dx /etc/service/recorder");
|
exec("svc -dx /etc/service/recorder");
|
||||||
exec("svc -dx /etc/service/recorder/log");
|
exec("svc -dx /etc/service/recorder/log");
|
||||||
exec("killall supervise");
|
exec("killall supervise");
|
||||||
|
exec("killall liquidsoap");
|
||||||
|
|
||||||
$pathnames = array("/usr/bin/airtime-pypo-start",
|
$pathnames = array("/usr/bin/airtime-pypo-start",
|
||||||
"/usr/bin/airtime-pypo-stop",
|
"/usr/bin/airtime-pypo-stop",
|
||||||
|
@ -819,6 +823,7 @@ AirtimeInstall::SetUniqueId();
|
||||||
AirtimeInstall::SetImportTimestamp();
|
AirtimeInstall::SetImportTimestamp();
|
||||||
|
|
||||||
AirtimeIni::CreateMonitFile();
|
AirtimeIni::CreateMonitFile();
|
||||||
|
exec("/etc/init.d/monit start");
|
||||||
|
|
||||||
AirtimeInstall::CreateSymlinksToUtils();
|
AirtimeInstall::CreateSymlinksToUtils();
|
||||||
|
|
||||||
|
|
|
@ -40,11 +40,14 @@ def to_unicode(obj, encoding='utf-8'):
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def encode_to(obj, encoding='utf-8'):
|
def encode_to(obj, encoding='utf-8'):
|
||||||
if isinstance(obj, basestring):
|
if isinstance(obj, unicode):
|
||||||
if not isinstance(obj, str):
|
obj = obj.encode(encoding)
|
||||||
obj = obj.encode(encoding)
|
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
def convert_dict_value_to_utf8(md):
|
||||||
|
#list comprehension to convert all values of md to utf-8
|
||||||
|
return dict([(item[0], encode_to(item[1], "utf-8")) for item in md.items()])
|
||||||
|
|
||||||
class ApiClientInterface:
|
class ApiClientInterface:
|
||||||
|
|
||||||
# Implementation: optional
|
# Implementation: optional
|
||||||
|
@ -412,6 +415,8 @@ class AirTimeApiClient(ApiClientInterface):
|
||||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||||
url = url.replace("%%mode%%", mode)
|
url = url.replace("%%mode%%", mode)
|
||||||
|
|
||||||
|
md = convert_dict_value_to_utf8(md)
|
||||||
|
|
||||||
data = urllib.urlencode(md)
|
data = urllib.urlencode(md)
|
||||||
req = urllib2.Request(url, data)
|
req = urllib2.Request(url, data)
|
||||||
|
|
||||||
|
@ -437,7 +442,7 @@ class AirTimeApiClient(ApiClientInterface):
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
response = None
|
response = None
|
||||||
logger.error("Exception with filepath %s: %s", md['MDATA_KEY_FILEPATH'], e)
|
logger.error("Exception with file %s: %s", md, e)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
self.api_client = api_client
|
self.api_client = api_client
|
||||||
self.create_dict = {}
|
self.create_dict = {}
|
||||||
|
|
||||||
|
|
||||||
def add_filepath_to_ignore(self, filepath):
|
def add_filepath_to_ignore(self, filepath):
|
||||||
self.ignore_event.add(filepath)
|
self.ignore_event.add(filepath)
|
||||||
|
|
||||||
|
@ -96,7 +97,6 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
# record the timestamp of the time on IN_CREATE event
|
# record the timestamp of the time on IN_CREATE event
|
||||||
self.create_dict[event.pathname] = time.time()
|
self.create_dict[event.pathname] = time.time()
|
||||||
|
|
||||||
|
|
||||||
#event.dir: True if the event was raised against a directory.
|
#event.dir: True if the event was raised against a directory.
|
||||||
#event.name: filename
|
#event.name: filename
|
||||||
#event.pathname: pathname (str): Concatenation of 'path' and 'name'.
|
#event.pathname: pathname (str): Concatenation of 'path' and 'name'.
|
||||||
|
@ -111,6 +111,7 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
self.create_dict.pop(event.pathname)
|
self.create_dict.pop(event.pathname)
|
||||||
self.handle_created_file(event.dir, event.pathname, event.name)
|
self.handle_created_file(event.dir, event.pathname, event.name)
|
||||||
|
|
||||||
|
|
||||||
def handle_created_file(self, dir, pathname, name):
|
def handle_created_file(self, dir, pathname, name):
|
||||||
if not dir:
|
if not dir:
|
||||||
self.logger.debug("PROCESS_IN_CLOSE_WRITE: %s, name: %s, pathname: %s ", dir, name, pathname)
|
self.logger.debug("PROCESS_IN_CLOSE_WRITE: %s, name: %s, pathname: %s ", dir, name, pathname)
|
||||||
|
|
|
@ -258,7 +258,8 @@ class CommandListener(Thread):
|
||||||
|
|
||||||
#remove show from shows to record.
|
#remove show from shows to record.
|
||||||
del self.shows_to_record[start_time]
|
del self.shows_to_record[start_time]
|
||||||
self.time_till_next_show = 3600
|
time_till_next_show = self.get_time_till_next_show()
|
||||||
|
self.time_till_next_show = time_till_next_show
|
||||||
except Exception,e :
|
except Exception,e :
|
||||||
self.logger.error(e)
|
self.logger.error(e)
|
||||||
else:
|
else:
|
||||||
|
@ -297,6 +298,7 @@ class CommandListener(Thread):
|
||||||
# start recording
|
# start recording
|
||||||
self.start_record()
|
self.start_record()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
self.logger.info(e)
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|
||||||
loops += 1
|
loops += 1
|
||||||
|
|
Loading…
Reference in New Issue