CC-5709: Airtime Analyzer
* Unbreak stuff
This commit is contained in:
parent
eb37b39406
commit
6952902b22
3 changed files with 10 additions and 9 deletions
|
@ -155,7 +155,7 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
//Our RESTful API takes "full_path" as a field, which we then split and translate to match
|
//Our RESTful API takes "full_path" as a field, which we then split and translate to match
|
||||||
//our internal schema. Internally, file path is stored relative to a directory, with the directory
|
//our internal schema. Internally, file path is stored relative to a directory, with the directory
|
||||||
//as a foreign key to cc_music_dirs.
|
//as a foreign key to cc_music_dirs.
|
||||||
if ($requestData["full_path"]) {
|
if (isset($requestData["full_path"])) {
|
||||||
Application_Model_Preference::updateDiskUsage(filesize($requestData["full_path"]));
|
Application_Model_Preference::updateDiskUsage(filesize($requestData["full_path"]));
|
||||||
|
|
||||||
$fullPath = $requestData["full_path"];
|
$fullPath = $requestData["full_path"];
|
||||||
|
|
|
@ -100,6 +100,7 @@ class MessageListener:
|
||||||
requeue=False) #Important that it doesn't requeue the message
|
requeue=False) #Important that it doesn't requeue the message
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
logging.exception(e)
|
||||||
#If ANY exception happens while processing a file, we're going to NACK to the
|
#If ANY exception happens while processing a file, we're going to NACK to the
|
||||||
#messaging server and tell it to remove the message from the queue.
|
#messaging server and tell it to remove the message from the queue.
|
||||||
#(NACK is a negative acknowledgement. We could use ACK instead, but this might come
|
#(NACK is a negative acknowledgement. We could use ACK instead, but this might come
|
||||||
|
@ -118,7 +119,6 @@ class MessageListener:
|
||||||
StatusReporter.report_failure_to_callback_url(callback_url, api_key, import_status=2,
|
StatusReporter.report_failure_to_callback_url(callback_url, api_key, import_status=2,
|
||||||
reason=u'An error occurred while importing this file')
|
reason=u'An error occurred while importing this file')
|
||||||
|
|
||||||
logging.exception(e)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# ACK at the very end, after the message has been successfully processed.
|
# ACK at the very end, after the message has been successfully processed.
|
||||||
|
|
|
@ -15,9 +15,9 @@ class StatusReporter():
|
||||||
put_payload = json.dumps(audio_metadata)
|
put_payload = json.dumps(audio_metadata)
|
||||||
logging.debug("sending http put with payload: " + put_payload)
|
logging.debug("sending http put with payload: " + put_payload)
|
||||||
r = requests.put(callback_url, data=put_payload,
|
r = requests.put(callback_url, data=put_payload,
|
||||||
auth=requests.auth.httpbasicauth(api_key, ''),
|
auth=requests.auth.HTTPBasicAuth(api_key, ''),
|
||||||
timeout=statusreporter._http_request_timeout)
|
timeout=StatusReporter._HTTP_REQUEST_TIMEOUT)
|
||||||
logging.debug("http request returned status: " + str(r.status_code))
|
logging.debug("HTTP request returned status: " + str(r.status_code))
|
||||||
logging.debug(r.text) # log the response body
|
logging.debug(r.text) # log the response body
|
||||||
|
|
||||||
#todo: queue up failed requests and try them again later.
|
#todo: queue up failed requests and try them again later.
|
||||||
|
@ -28,16 +28,17 @@ class StatusReporter():
|
||||||
# TODO: Make import_status is an int?
|
# TODO: Make import_status is an int?
|
||||||
|
|
||||||
logging.debug("Reporting import failure to Airtime REST API...")
|
logging.debug("Reporting import failure to Airtime REST API...")
|
||||||
|
audio_metadata = dict()
|
||||||
audio_metadata["import_status"] = import_status
|
audio_metadata["import_status"] = import_status
|
||||||
audio_metadata["comment"] = reason # hack attack
|
audio_metadata["comment"] = reason # hack attack
|
||||||
put_payload = json.dumps(audio_metadata)
|
put_payload = json.dumps(audio_metadata)
|
||||||
logging.debug("sending http put with payload: " + put_payload)
|
logging.debug("sending http put with payload: " + put_payload)
|
||||||
r = requests.put(callback_url, data=put_payload,
|
r = requests.put(callback_url, data=put_payload,
|
||||||
auth=requests.auth.httpbasicauth(api_key, ''),
|
auth=requests.auth.HTTPBasicAuth(api_key, ''),
|
||||||
timeout=statusreporter._http_request_timeout)
|
timeout=StatusReporter._HTTP_REQUEST_TIMEOUT)
|
||||||
logging.debug("http request returned status: " + str(r.status_code))
|
logging.debug("HTTP request returned status: " + str(r.status_code))
|
||||||
logging.debug(r.text) # log the response body
|
logging.debug(r.text) # log the response body
|
||||||
|
|
||||||
#todo: queue up failed requests and try them again later.
|
#TODO: queue up failed requests and try them again later.
|
||||||
r.raise_for_status() # raise an exception if there was an http error code returned
|
r.raise_for_status() # raise an exception if there was an http error code returned
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue