From 2556f3ba3021307f102fee7554f64a48405d0f02 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 29 Oct 2012 14:57:43 -0400 Subject: [PATCH] added error handling on the caller of replaygain instead of in api client --- python_apps/api_clients/api_client.py | 13 ++++--------- .../media/update/replaygainupdater.py | 5 ++++- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index a1b4aebc4..b8aa7eec2 100644 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -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): diff --git a/python_apps/media-monitor2/media/update/replaygainupdater.py b/python_apps/media-monitor2/media/update/replaygainupdater.py index a92cbb357..df48f09de 100644 --- a/python_apps/media-monitor2/media/update/replaygainupdater.py +++ b/python_apps/media-monitor2/media/update/replaygainupdater.py @@ -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)