Merge branch 'saas-dev' into saas-showbuilder

This commit is contained in:
Albert Santoni 2015-08-24 16:53:32 -04:00
commit e188fcde32
5 changed files with 17 additions and 21 deletions

View File

@ -1441,7 +1441,8 @@ class Application_Model_Preference
// SAAS-876 - Toggle indicating whether user is using custom stream settings // SAAS-876 - Toggle indicating whether user is using custom stream settings
public static function getUsingCustomStreamSettings() { public static function getUsingCustomStreamSettings() {
return self::getValue("using_custom_stream_settings"); $val = self::getValue("using_custom_stream_settings");
return empty($val) ? false : $val;
} }
public static function setUsingCustomStreamSettings($value) { public static function setUsingCustomStreamSettings($value) {

View File

@ -1019,9 +1019,11 @@ SQL;
$media_id = $item['file_id']; $media_id = $item['file_id'];
$storedFile = Application_Model_StoredFile::RecallById($media_id); $storedFile = Application_Model_StoredFile::RecallById($media_id);
$file = $storedFile->getPropelOrm(); $file = $storedFile->getPropelOrm();
$uri = $file->getAbsoluteFilePath(); //Even local files are downloaded through the REST API in case we need to transform
//their filenames (eg. in the case of a bad file extension, because Liquidsoap won't play them)
$uri = Application_Common_HTTPHelper::getStationUrl() . "/rest/media/" . $media_id;
//$uri = $file->getAbsoluteFilePath();
$baseUrl = Application_Common_OsPath::getBaseDir();
$filesize = $file->getFileSize(); $filesize = $file->getFileSize();
self::createFileScheduleEvent($data, $item, $media_id, $uri, $filesize); self::createFileScheduleEvent($data, $item, $media_id, $uri, $filesize);
} }

View File

@ -313,8 +313,10 @@ else
fi fi
# Check if composer exists and install if it doesn't # Check if composer exists and install if it doesn't
set +e
eval hash "composer" 2>/dev/null eval hash "composer" 2>/dev/null
commandFound=$? commandFound=$?
set -e
if [[ ! ${commandFound} -eq 0 ]]; then if [[ ! ${commandFound} -eq 0 ]]; then
curl -sS https://getcomposer.org/installer | php curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer mv composer.phar /usr/local/bin/composer

View File

@ -345,9 +345,8 @@ class PypoFetch(Thread):
for key in media: for key in media:
media_item = media[key] media_item = media[key]
if (media_item['type'] == 'file'): if (media_item['type'] == 'file'):
self.sanity_check_media_item(media_item) fileExt = self.sanity_check_media_item(media_item)
fileExt = os.path.splitext(media_item['uri'])[1] dst = os.path.join(download_dir, unicode(media_item['id']) + unicode(fileExt))
dst = os.path.join(download_dir, unicode(media_item['id']) + fileExt)
media_item['dst'] = dst media_item['dst'] = dst
media_item['file_ready'] = False media_item['file_ready'] = False
media_filtered[key] = media_item media_filtered[key] = media_item
@ -377,21 +376,10 @@ class PypoFetch(Thread):
start = datetime.strptime(media_item['start'], "%Y-%m-%d-%H-%M-%S") start = datetime.strptime(media_item['start'], "%Y-%m-%d-%H-%M-%S")
end = datetime.strptime(media_item['end'], "%Y-%m-%d-%H-%M-%S") end = datetime.strptime(media_item['end'], "%Y-%m-%d-%H-%M-%S")
root, ext = os.path.splitext(media_item['uri'])
mime = media_item['metadata']['mime'] mime = media_item['metadata']['mime']
mimetypes.init() mimetypes.init(["%s/mime.types" % os.path.dirname(os.path.realpath(__file__))])
mime_ext = mimetypes.guess_extension(mime, strict=False) mime_ext = mimetypes.guess_extension(mime, strict=False)
if mime_ext is None:
mimes = mimetypes.read_mime_types("%s/mime.types" % os.path.dirname(os.path.realpath(__file__)))
for k, v in mimes.iteritems():
if v == mime:
mime_ext = k
if mime_ext is not None and mime_ext != ext:
self.logger.info("Invalid extension %s for file %s, changing to %s" % (ext, root, mime_ext))
media_item['uri'] = root + mime_ext
length1 = pure.date_interval_to_seconds(end - start) length1 = pure.date_interval_to_seconds(end - start)
length2 = media_item['cue_out'] - media_item['cue_in'] length2 = media_item['cue_out'] - media_item['cue_in']
@ -400,6 +388,10 @@ class PypoFetch(Thread):
self.logger.error("cue_out - cue_in length: %s", length2) self.logger.error("cue_out - cue_in length: %s", length2)
self.logger.error("Two lengths are not equal!!!") self.logger.error("Two lengths are not equal!!!")
media_item['file_ext'] = mime_ext
return mime_ext
def is_file_opened(self, path): def is_file_opened(self, path):
#Capture stderr to avoid polluting py-interpreter.log #Capture stderr to avoid polluting py-interpreter.log
proc = Popen(["lsof", path], stdout=PIPE, stderr=PIPE) proc = Popen(["lsof", path], stdout=PIPE, stderr=PIPE)
@ -418,8 +410,7 @@ class PypoFetch(Thread):
for mkey in media: for mkey in media:
media_item = media[mkey] media_item = media[mkey]
if media_item['type'] == 'file': if media_item['type'] == 'file':
fileExt = os.path.splitext(media_item['uri'])[1] scheduled_file_set.add(unicode(media_item["id"]) + unicode(media_item["file_ext"]))
scheduled_file_set.add(unicode(media_item["id"]) + fileExt)
expired_files = cached_file_set - scheduled_file_set expired_files = cached_file_set - scheduled_file_set

View File

@ -61,7 +61,7 @@ class PypoFile(Thread):
media_item['file_ready'] = not do_copy media_item['file_ready'] = not do_copy
if do_copy: if do_copy:
self.logger.debug("copying from %s to local cache %s" % (src, dst)) self.logger.info("copying from %s to local cache %s" % (src, dst))
try: try:
CONFIG_SECTION = "general" CONFIG_SECTION = "general"
username = self._config.get(CONFIG_SECTION, 'api_key') username = self._config.get(CONFIG_SECTION, 'api_key')