Merge branch 'saas' into saas-embed-player

This commit is contained in:
drigato 2015-04-09 15:09:03 -04:00
commit fbcd5bc5bd
16 changed files with 141 additions and 47 deletions

View file

@ -21,7 +21,9 @@ class AnalyzerPipeline:
so that if it crashes, it does not kill the entire airtime_analyzer daemon and
the failure to import can be reported back to the web application.
"""
IMPORT_STATUS_FAILED = 2
@staticmethod
def run_analysis(queue, audio_file_path, import_directory, original_filename, storage_backend, file_prefix, cloud_storage_config):
"""Analyze and import an audio file, and put all extracted metadata into queue.
@ -86,12 +88,12 @@ class AnalyzerPipeline:
queue.put(metadata)
except UnplayableFileError as e:
logging.exception(e)
metadata["import_status"] = 2
metadata["import_status"] = IMPORT_STATUS_FAILED
metadata["reason"] = "The file could not be played."
raise e
except Exception as e:
# Ensures the traceback for this child process gets written to our log files:
logging.exception(e)
logging.exception(e)
raise e
@staticmethod

View file

@ -226,18 +226,19 @@ class MessageListener:
else:
raise Exception("Analyzer process terminated unexpectedly.")
'''
metadata = {}
q = Queue.Queue()
try:
AnalyzerPipeline.run_analysis(q, audio_file_path, import_directory, original_filename, storage_backend, file_prefix, cloud_storage_config)
results = q.get()
metadata = q.get()
except Exception as e:
logging.error("Analyzer pipeline exception", e)
pass
logging.error("Analyzer pipeline exception: %s" % str(e))
metadata["import_status"] = AnalyzerPipeline.IMPORT_STATUS_FAILED
# Ensure our queue doesn't fill up and block due to unexpected behaviour. Defensive code.
while not q.empty():
q.get()
return results
return metadata

View file

@ -27,6 +27,6 @@ class PlayabilityAnalyzer(Analyzer):
logging.warn("Failed to run: %s - %s. %s" % (command[0], e.strerror, "Do you have liquidsoap installed?"))
except (subprocess.CalledProcessError, Exception) as e: # liquidsoap returned an error code
logging.warn(e)
raise UnplayableFileError
raise UnplayableFileError()
return metadata

View file

@ -25,7 +25,7 @@ class PicklableHttpRequest:
auth=requests.auth.HTTPBasicAuth(self.api_key, ''))
def process_http_requests(ipc_queue, http_retry_queue_path):
''' Runs in a separate process and performs all the HTTP requests where we're
''' Runs in a separate thread and performs all the HTTP requests where we're
reporting extracted audio file metadata or errors back to the Airtime web application.
This process also checks every 5 seconds if there's failed HTTP requests that we