added error handling on the caller of replaygain instead of in api client

This commit is contained in:
Rudi Grinberg 2012-10-29 14:57:43 -04:00
parent 18d8e24a56
commit 2556f3ba30
2 changed files with 8 additions and 10 deletions

View File

@ -705,17 +705,12 @@ class AirtimeApiClient(object):
'pairs' is a list of pairs in (x, y), where x is the file's database
row id and y is the file's replay_gain value in dB
"""
#http://localhost/api/update-replay-gain-value/
try:
url = self.construct_url("update_replay_gain_value")
data = urllib.urlencode({'data': json.dumps(pairs)})
request = urllib2.Request(url, data)
url = self.construct_url("update_replay_gain_value")
data = urllib.urlencode({'data': json.dumps(pairs)})
request = urllib2.Request(url, data)
self.logger.debug(self.get_response_from_server(request))
except Exception, e:
self.logger.error("Exception: %s", e)
raise
self.logger.debug(self.get_response_from_server(request))
def notify_webstream_data(self, data, media_id):

View File

@ -56,7 +56,10 @@ class ReplayGainUpdater(Thread, Loggable):
full_path = os.path.join(dir_path, f['fp'])
processed_data.append((f['id'], replaygain.calculate_replay_gain(full_path)))
self.api_client.update_replay_gain_values(processed_data)
try:
self.api_client.update_replay_gain_values(processed_data)
except Exception as e: self.unexpected_exception(e)
if len(files) == 0: break
self.logger.info("Processed: %d songs" % total)