Merge branch 'master' of dev.sourcefabric.org:airtime
This commit is contained in:
commit
80cdd3f2e2
|
@ -38,7 +38,11 @@ class Application_Model_Preference
|
|||
$result = Application_Common_Database::prepareAndExecute($sql, $paramMap, 'column');
|
||||
|
||||
$paramMap = array();
|
||||
if ($result == 1) {
|
||||
if ($result > 1) {
|
||||
//this case should not happen.
|
||||
throw new Exception("Invalid number of results returned. Should be ".
|
||||
"0 or 1, but is '$result' instead");
|
||||
} elseif ($result == 1) {
|
||||
// result found
|
||||
if (is_null($id) || !$isUserValue) {
|
||||
// system pref
|
||||
|
@ -80,7 +84,7 @@ class Application_Model_Preference
|
|||
|
||||
} catch (Exception $e) {
|
||||
header('HTTP/1.0 503 Service Unavailable');
|
||||
Logging::info("Could not connect to database: ".$e->getMessage());
|
||||
Logging::info("Database error: ".$e->getMessage());
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -432,6 +432,7 @@ class PypoFetch(Thread):
|
|||
for key in media:
|
||||
media_item = media[key]
|
||||
if (media_item['type'] == 'file'):
|
||||
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']) + fileExt)
|
||||
media_item['dst'] = dst
|
||||
|
@ -455,6 +456,20 @@ class PypoFetch(Thread):
|
|||
try: self.cache_cleanup(media)
|
||||
except Exception, e: self.logger.error("%s", e)
|
||||
|
||||
#do basic validation of file parameters. Useful for debugging
|
||||
#purposes
|
||||
def sanity_check_media_item(self, media_item):
|
||||
start = datetime.strptime(media_item['start'], "%Y-%m-%d-%H-%M-%S")
|
||||
end = datetime.strptime(media_item['end'], "%Y-%m-%d-%H-%M-%S")
|
||||
|
||||
length1 = (end - start).total_seconds()
|
||||
length2 = media_item['cue_out'] - media_item['cue_in']
|
||||
|
||||
if abs(length2 - length1) > 1:
|
||||
self.logger.error("end - start length: %s", length1)
|
||||
self.logger.error("cue_out - cue_in length: %s", length2)
|
||||
self.logger.error("Two lengths are not equal!!!")
|
||||
|
||||
def is_file_opened(self, path):
|
||||
#Capture stderr to avoid polluting py-interpreter.log
|
||||
proc = Popen(["lsof", path], stdout=PIPE, stderr=PIPE)
|
||||
|
|
Loading…
Reference in New Issue