Merge branch 'cc-5709-airtime-analyzer-saas' of github.com:sourcefabric/Airtime into cc-5709-airtime-analyzer-saas
This commit is contained in:
commit
56d85f1ac8
|
@ -60,12 +60,17 @@ class PluploadController extends Zend_Controller_Action
|
|||
|
||||
foreach ($recentUploads as $upload)
|
||||
{
|
||||
$upload->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
//array_push($uploadsArray, $upload); //TODO: $this->sanitizeResponse($upload));
|
||||
$upload = $upload->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
//TODO: $this->sanitizeResponse($upload));
|
||||
$utcTimezone = new DateTimeZone("UTC");
|
||||
$displayTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
|
||||
$upload['utime'] = new DateTime($upload['utime'], $utcTimezone);
|
||||
$upload['utime']->setTimeZone($displayTimezone);
|
||||
$upload['utime'] = $upload['utime']->format('Y-m-d H:i:s');
|
||||
|
||||
//$this->_helper->json->sendJson($upload->asJson());
|
||||
//TODO: Invoke sanitization here
|
||||
array_push($uploadsArray, $upload->toArray(BasePeer::TYPE_FIELDNAME));
|
||||
array_push($uploadsArray, $upload);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -982,6 +982,7 @@ SQL;
|
|||
} else {
|
||||
$uid = $user->getId();
|
||||
}
|
||||
/*
|
||||
$id_file = "$audio_stor.identifier";
|
||||
if (file_put_contents($id_file, $uid) === false) {
|
||||
Logging::info("Could not write file to identify user: '$uid'");
|
||||
|
@ -991,7 +992,8 @@ SQL;
|
|||
} else {
|
||||
Logging::info("Successfully written identification file for
|
||||
uploaded '$audio_stor'");
|
||||
}
|
||||
}*/
|
||||
|
||||
//if the uploaded file is not UTF-8 encoded, let's encode it. Assuming source
|
||||
//encoding is ISO-8859-1
|
||||
$audio_stor = mb_detect_encoding($audio_stor, "UTF-8") == "UTF-8" ? $audio_stor : utf8_encode($audio_stor);
|
||||
|
@ -1004,7 +1006,7 @@ SQL;
|
|||
//the file wasn't uploaded and they should check if there .
|
||||
//is enough disk space .
|
||||
unlink($audio_file); //remove the file after failed rename
|
||||
unlink($id_file); // Also remove the identifier file
|
||||
//unlink($id_file); // Also remove the identifier file
|
||||
|
||||
throw new Exception("The file was not uploaded, this error can occur if the computer "
|
||||
."hard drive does not have enough disk space or the stor "
|
||||
|
|
|
@ -335,7 +335,15 @@ class Rest_MediaController extends Zend_Rest_Controller
|
|||
|
||||
$tempFilePath = $_FILES['file']['tmp_name'];
|
||||
$tempFileName = basename($tempFilePath);
|
||||
|
||||
|
||||
//Only accept files with a file extension that we support.
|
||||
$fileExtension = pathinfo($originalFilename, PATHINFO_EXTENSION);
|
||||
if (!in_array(strtolower($fileExtension), explode(",", "ogg,mp3,oga,flac,wav,m4a,mp4,opus")))
|
||||
{
|
||||
@unlink($tempFilePath);
|
||||
throw new Exception("Bad file extension.");
|
||||
}
|
||||
|
||||
//TODO: Remove uploadFileAction from ApiController.php **IMPORTANT** - It's used by the recorder daemon...
|
||||
|
||||
$storDir = Application_Model_MusicDir::getStorDir();
|
||||
|
@ -346,7 +354,9 @@ class Rest_MediaController extends Zend_Rest_Controller
|
|||
//and accessible by airtime_analyzer which could be running on a different machine.
|
||||
$newTempFilePath = Application_Model_StoredFile::copyFileToStor($tempFilePath, $originalFilename);
|
||||
} catch (Exception $e) {
|
||||
@unlink($tempFilePath);
|
||||
Logging::error($e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
Logging::info($newTempFilePath);
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
|
||||
<div id="recent_uploads_filter">
|
||||
<form>
|
||||
<input type="radio" name="upload_status" id="upload_status_all" checked></input><label for="upload_status_all">All</label>
|
||||
<input type="radio" name="upload_status" id="upload_status_failed"></input><label for="upload_status_failed">Failed</label>
|
||||
<input type="radio" name="upload_status" id="upload_status_pending"></input><label for="upload_status_pending">Pending</label>
|
||||
<input type="radio" name="upload_status" id="upload_status_all" checked></input><label for="upload_status_all"><?php echo _("All")?></label>
|
||||
<input type="radio" name="upload_status" id="upload_status_failed"></input><label for="upload_status_failed"><?php echo _("Failed")?></label>
|
||||
<input type="radio" name="upload_status" id="upload_status_pending"></input><label for="upload_status_pending"><?php echo _("Pending")?></label>
|
||||
</form>
|
||||
</div>
|
||||
<H2>Recent Uploads</H2>
|
||||
<H2><?php echo _("Recent Uploads")?></H2>
|
||||
<table id="recent_uploads_table" class="lib-content ui-widget ui-widget-content block-shadow alpha-block "></table>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -4,6 +4,7 @@ import ConfigParser
|
|||
import logging
|
||||
import logging.handlers
|
||||
import sys
|
||||
from functools import partial
|
||||
from metadata_analyzer import MetadataAnalyzer
|
||||
from replaygain_analyzer import ReplayGainAnalyzer
|
||||
from message_listener import MessageListener
|
||||
|
@ -26,7 +27,7 @@ class AirtimeAnalyzerServer:
|
|||
|
||||
# Read our config file
|
||||
rabbitmq_config = self.read_config_file(config_path)
|
||||
|
||||
|
||||
# Start listening for RabbitMQ messages telling us about newly
|
||||
# uploaded files.
|
||||
self._msg_listener = MessageListener(rabbitmq_config)
|
||||
|
@ -74,4 +75,4 @@ class AirtimeAnalyzerServer:
|
|||
exit(-1)
|
||||
|
||||
return config
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ import sys
|
|||
import pika
|
||||
import json
|
||||
import time
|
||||
import select
|
||||
import signal
|
||||
import logging
|
||||
import multiprocessing
|
||||
from analyzer_pipeline import AnalyzerPipeline
|
||||
|
@ -59,6 +61,8 @@ class MessageListener:
|
|||
Keyword arguments:
|
||||
config: A ConfigParser object containing the [rabbitmq] configuration.
|
||||
'''
|
||||
|
||||
self._shutdown = False
|
||||
|
||||
# Read the RabbitMQ connection settings from the config file
|
||||
# The exceptions throw here by default give good error messages.
|
||||
|
@ -68,21 +72,31 @@ class MessageListener:
|
|||
self._username = config.get(RMQ_CONFIG_SECTION, 'user')
|
||||
self._password = config.get(RMQ_CONFIG_SECTION, 'password')
|
||||
self._vhost = config.get(RMQ_CONFIG_SECTION, 'vhost')
|
||||
|
||||
# Set up a signal handler so we can shutdown gracefully
|
||||
# For some reason, this signal handler must be set up here. I'd rather
|
||||
# put it in AirtimeAnalyzerServer, but it doesn't work there (something to do
|
||||
# with pika's SIGTERM handler interfering with it, I think...)
|
||||
signal.signal(signal.SIGTERM, self.graceful_shutdown)
|
||||
|
||||
while True:
|
||||
while not self._shutdown:
|
||||
try:
|
||||
self.connect_to_messaging_server()
|
||||
self.wait_for_messages()
|
||||
except KeyboardInterrupt:
|
||||
self.disconnect_from_messaging_server()
|
||||
break
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
break # Break out of the while loop and exit the application
|
||||
except select.error:
|
||||
pass
|
||||
except pika.exceptions.AMQPError as e:
|
||||
if self._shutdown:
|
||||
break
|
||||
logging.error("Connection to message queue failed. ")
|
||||
logging.error(e)
|
||||
logging.info("Retrying in 5 seconds...")
|
||||
time.sleep(5)
|
||||
|
||||
self._connection.close()
|
||||
self.disconnect_from_messaging_server()
|
||||
logging.info("Exiting cleanly.")
|
||||
|
||||
|
||||
def connect_to_messaging_server(self):
|
||||
|
@ -107,7 +121,12 @@ class MessageListener:
|
|||
def disconnect_from_messaging_server(self):
|
||||
'''Stop consuming RabbitMQ messages and disconnect'''
|
||||
self._channel.stop_consuming()
|
||||
|
||||
self._connection.close()
|
||||
|
||||
def graceful_shutdown(self, signum, frame):
|
||||
'''Disconnect and break out of the message listening loop'''
|
||||
self._shutdown = True
|
||||
self.disconnect_from_message_listener()
|
||||
|
||||
@staticmethod
|
||||
def msg_received_callback(channel, method_frame, header_frame, body):
|
||||
|
|
Loading…
Reference in New Issue