cc-4105: fixed bug where api client wasn't being initialized right by replaygain updater. updated apiclient to better detect such bad usage

This commit is contained in:
Rudi Grinberg 2012-08-09 12:13:44 -04:00
parent 3c82497c34
commit 5bc170ba31
3 changed files with 10 additions and 8 deletions

View File

@ -52,6 +52,9 @@ class AirtimeApiClient():
@staticmethod
def create_right_config(log=None,config_path=None):
if config_path: AirtimeApiClient.default_config = config_path
elif (not AirtimeApiClient.default_config):
raise ValueError("Cannot slip config_path attribute when it has \
never been passed yet")
return AirtimeApiClient( logger=None, config_path=AirtimeApiClient.default_config )
def __init__(self, logger=None,config_path='/etc/airtime/api_client.cfg'):
@ -465,6 +468,7 @@ class AirtimeApiClient():
except Exception, e:
response = None
logger.error("Exception: %s", e)
self.logger.debug(traceback.format_exc())
return response

View File

@ -4,7 +4,6 @@ import traceback
import os
import time
from api_clients import api_client
from media.update import replaygain
from media.monitor.log import Loggable
@ -23,17 +22,16 @@ class ReplayGainUpdater(Thread, Loggable):
"""
@staticmethod
def start_reply_gain():
me = ReplayGainUpdater()
def start_reply_gain(apc):
me = ReplayGainUpdater(apc)
me.daemon = True
me.start()
def __init__(self):
def __init__(self,apc):
Thread.__init__(self)
self.api_client = api_client.AirtimeApiClient.create_right_config()
self.api_client = apc
def main(self):
raw_response = self.api_client.list_all_watched_dirs()
if 'dirs' not in raw_response:
self.logger.error("Could not get a list of watched directories \

View File

@ -57,11 +57,11 @@ watch_syncer = WatchSyncer(signal='watch',
chunking_number=config['chunking_number'],
timeout=config['request_max_wait'])
ReplayGainUpdater.start_reply_gain()
apiclient = apc.AirtimeApiClient.create_right_config(log=log,
config_path=api_client_config)
ReplayGainUpdater.start_reply_gain(apiclient)
# TODO : Need to do setup_media_monitor call somewhere around here to get
# import/organize dirs
sdb = AirtimeDB(apiclient)