From afb55c7b518b1bee61470bfea0dc58ef9d63aeb1 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 5 Apr 2013 14:20:34 -0400 Subject: [PATCH 1/2] CC-5038: Silan error: list index out of range cosmetic bug fix to prevent so much logging --- python_apps/pypo/media/update/silananalyzer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python_apps/pypo/media/update/silananalyzer.py b/python_apps/pypo/media/update/silananalyzer.py index 4d93deddf..0e8f14027 100644 --- a/python_apps/pypo/media/update/silananalyzer.py +++ b/python_apps/pypo/media/update/silananalyzer.py @@ -47,8 +47,9 @@ class SilanAnalyzer(Thread): proc = subprocess.Popen(command, stdout=subprocess.PIPE) out = proc.communicate()[0].strip('\r\n') info = json.loads(out) - data['cuein'] = str('{0:f}'.format(info['sound'][0][0])) - data['cueout'] = str('{0:f}'.format(info['sound'][-1][1])) + if len(info['sound']) >= 2: + data['cuein'] = str('{0:f}'.format(info['sound'][0][0])) + data['cueout'] = str('{0:f}'.format(info['sound'][-1][1])) except Exception, e: self.logger.error(str(command)) self.logger.error(e) From d1f655d79d0d0e4edb575ea0449e39e622a73b85 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 5 Apr 2013 15:32:44 -0400 Subject: [PATCH 2/2] CC-5038: Silan error: list index out of range -fixed --- .../application/controllers/ApiController.php | 6 +++--- python_apps/pypo/media/update/replaygainupdater.py | 3 ++- python_apps/pypo/media/update/silananalyzer.py | 12 +++++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 88aa95e60..f4024c8a0 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -971,14 +971,14 @@ class ApiController extends Zend_Controller_Action $this->_helper->viewRenderer->setNoRender(true); $request = $this->getRequest(); - $data = json_decode($request->getParam('data')); + $data = json_decode($request->getParam('data'), $assoc = true); foreach ($data as $pair) { list($id, $info) = $pair; // TODO : move this code into model -- RG - $cuein = $info->cuein; - $cueout = $info->cueout; $file = Application_Model_StoredFile::Recall($p_id = $id)->getPropelOrm(); + $cuein = isset($info['cuein']) ? $info['cuein'] : 0; + $cueout = isset($info['cueout']) ? $info['cueout'] : $file->getDbLength(); $file->setDbCuein($cuein); $file->setDbCueout($cueout); $file->setDbSilanCheck(true); diff --git a/python_apps/pypo/media/update/replaygainupdater.py b/python_apps/pypo/media/update/replaygainupdater.py index 5466e30ce..daf63d54d 100644 --- a/python_apps/pypo/media/update/replaygainupdater.py +++ b/python_apps/pypo/media/update/replaygainupdater.py @@ -58,7 +58,8 @@ class ReplayGainUpdater(Thread): total += 1 try: - self.api_client.update_replay_gain_values(processed_data) + if len(processed_data): + self.api_client.update_replay_gain_values(processed_data) except Exception as e: self.logger.error(e) self.logger.debug(traceback.format_exc()) diff --git a/python_apps/pypo/media/update/silananalyzer.py b/python_apps/pypo/media/update/silananalyzer.py index 0e8f14027..03441d614 100644 --- a/python_apps/pypo/media/update/silananalyzer.py +++ b/python_apps/pypo/media/update/silananalyzer.py @@ -45,11 +45,13 @@ class SilanAnalyzer(Thread): command = ['nice', '-n', '19', 'silan', '-b', '-f', 'JSON', full_path] try: proc = subprocess.Popen(command, stdout=subprocess.PIPE) - out = proc.communicate()[0].strip('\r\n') - info = json.loads(out) - if len(info['sound']) >= 2: - data['cuein'] = str('{0:f}'.format(info['sound'][0][0])) - data['cueout'] = str('{0:f}'.format(info['sound'][-1][1])) + comm = proc.communicate() + if len(comm): + out = comm[0].strip('\r\n') + info = json.loads(out) + if len(info['sound']) >= 2: + data['cuein'] = str('{0:f}'.format(info['sound'][0][0])) + data['cueout'] = str('{0:f}'.format(info['sound'][-1][1])) except Exception, e: self.logger.error(str(command)) self.logger.error(e)