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);
|
||||
header('Content-Disposition: attachment; filename="'.$file_base_name.'"');
|
||||
}
|
||||
$logger->info("Sending $filepath");
|
||||
header("Content-Length: " . filesize($filepath));
|
||||
|
||||
// !! binary mode !!
|
||||
|
@ -539,6 +540,7 @@ class ApiController extends Zend_Controller_Action
|
|||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||
$filepath = str_replace("\\", "", $filepath);
|
||||
$files = Application_Model_StoredFile::RecallByPartialFilepath($filepath);
|
||||
|
||||
foreach($files as $file){
|
||||
$file->delete();
|
||||
}
|
||||
|
|
|
@ -281,6 +281,7 @@ class Application_Model_MusicDir {
|
|||
}
|
||||
|
||||
public static function removeWatchedDir($p_dir){
|
||||
|
||||
$real_path = realpath($p_dir)."/";
|
||||
if($real_path != "/"){
|
||||
$p_dir = $real_path;
|
||||
|
|
|
@ -597,6 +597,27 @@ class Application_Model_StoredFile {
|
|||
}
|
||||
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) {
|
||||
global $CC_CONFIG;
|
||||
|
@ -751,7 +772,7 @@ class Application_Model_StoredFile {
|
|||
$chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0;
|
||||
$chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0;
|
||||
$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
|
||||
//this needs fixing for songs not in ascii.
|
||||
//$fileName = preg_replace('/[^\w\._]+/', '', $fileName);
|
||||
|
|
|
@ -677,7 +677,10 @@ class Airtime190Upgrade{
|
|||
->findOne();
|
||||
|
||||
/* 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;
|
||||
$propel_stor_dir->setDirectory($stor_dir);
|
||||
$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/log");
|
||||
exec("killall supervise");
|
||||
exec("killall liquidsoap");
|
||||
|
||||
$pathnames = array("/usr/bin/airtime-pypo-start",
|
||||
"/usr/bin/airtime-pypo-stop",
|
||||
|
@ -819,6 +823,7 @@ AirtimeInstall::SetUniqueId();
|
|||
AirtimeInstall::SetImportTimestamp();
|
||||
|
||||
AirtimeIni::CreateMonitFile();
|
||||
exec("/etc/init.d/monit start");
|
||||
|
||||
AirtimeInstall::CreateSymlinksToUtils();
|
||||
|
||||
|
|
|
@ -40,10 +40,13 @@ def to_unicode(obj, encoding='utf-8'):
|
|||
return obj
|
||||
|
||||
def encode_to(obj, encoding='utf-8'):
|
||||
if isinstance(obj, basestring):
|
||||
if not isinstance(obj, str):
|
||||
obj = obj.encode(encoding)
|
||||
if isinstance(obj, unicode):
|
||||
obj = obj.encode(encoding)
|
||||
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:
|
||||
|
||||
|
@ -411,7 +414,9 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["update_media_url"])
|
||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||
url = url.replace("%%mode%%", mode)
|
||||
|
||||
|
||||
md = convert_dict_value_to_utf8(md)
|
||||
|
||||
data = urllib.urlencode(md)
|
||||
req = urllib2.Request(url, data)
|
||||
|
||||
|
@ -437,7 +442,7 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
|
||||
except Exception, e:
|
||||
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
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
self.api_client = api_client
|
||||
self.create_dict = {}
|
||||
|
||||
|
||||
def add_filepath_to_ignore(self, filepath):
|
||||
self.ignore_event.add(filepath)
|
||||
|
||||
|
@ -96,7 +97,6 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
# record the timestamp of the time on IN_CREATE event
|
||||
self.create_dict[event.pathname] = time.time()
|
||||
|
||||
|
||||
#event.dir: True if the event was raised against a directory.
|
||||
#event.name: filename
|
||||
#event.pathname: pathname (str): Concatenation of 'path' and 'name'.
|
||||
|
@ -110,6 +110,7 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
# detele corresponding entry from create_dict
|
||||
self.create_dict.pop(event.pathname)
|
||||
self.handle_created_file(event.dir, event.pathname, event.name)
|
||||
|
||||
|
||||
def handle_created_file(self, dir, pathname, name):
|
||||
if not dir:
|
||||
|
|
|
@ -258,7 +258,8 @@ class CommandListener(Thread):
|
|||
|
||||
#remove show from shows to record.
|
||||
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 :
|
||||
self.logger.error(e)
|
||||
else:
|
||||
|
@ -297,6 +298,7 @@ class CommandListener(Thread):
|
|||
# start recording
|
||||
self.start_record()
|
||||
except Exception, e:
|
||||
self.logger.info(e)
|
||||
time.sleep(3)
|
||||
|
||||
loops += 1
|
||||
|
|
Loading…
Reference in New Issue