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:
parent
3c82497c34
commit
5bc170ba31
|
@ -52,6 +52,9 @@ class AirtimeApiClient():
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_right_config(log=None,config_path=None):
|
def create_right_config(log=None,config_path=None):
|
||||||
if config_path: AirtimeApiClient.default_config = config_path
|
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 )
|
return AirtimeApiClient( logger=None, config_path=AirtimeApiClient.default_config )
|
||||||
|
|
||||||
def __init__(self, logger=None,config_path='/etc/airtime/api_client.cfg'):
|
def __init__(self, logger=None,config_path='/etc/airtime/api_client.cfg'):
|
||||||
|
@ -465,6 +468,7 @@ class AirtimeApiClient():
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
response = None
|
response = None
|
||||||
logger.error("Exception: %s", e)
|
logger.error("Exception: %s", e)
|
||||||
|
self.logger.debug(traceback.format_exc())
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import traceback
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from api_clients import api_client
|
|
||||||
from media.update import replaygain
|
from media.update import replaygain
|
||||||
from media.monitor.log import Loggable
|
from media.monitor.log import Loggable
|
||||||
|
|
||||||
|
@ -23,17 +22,16 @@ class ReplayGainUpdater(Thread, Loggable):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def start_reply_gain():
|
def start_reply_gain(apc):
|
||||||
me = ReplayGainUpdater()
|
me = ReplayGainUpdater(apc)
|
||||||
me.daemon = True
|
me.daemon = True
|
||||||
me.start()
|
me.start()
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self,apc):
|
||||||
Thread.__init__(self)
|
Thread.__init__(self)
|
||||||
self.api_client = api_client.AirtimeApiClient.create_right_config()
|
self.api_client = apc
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
|
|
||||||
raw_response = self.api_client.list_all_watched_dirs()
|
raw_response = self.api_client.list_all_watched_dirs()
|
||||||
if 'dirs' not in raw_response:
|
if 'dirs' not in raw_response:
|
||||||
self.logger.error("Could not get a list of watched directories \
|
self.logger.error("Could not get a list of watched directories \
|
||||||
|
|
|
@ -57,11 +57,11 @@ watch_syncer = WatchSyncer(signal='watch',
|
||||||
chunking_number=config['chunking_number'],
|
chunking_number=config['chunking_number'],
|
||||||
timeout=config['request_max_wait'])
|
timeout=config['request_max_wait'])
|
||||||
|
|
||||||
ReplayGainUpdater.start_reply_gain()
|
|
||||||
|
|
||||||
apiclient = apc.AirtimeApiClient.create_right_config(log=log,
|
apiclient = apc.AirtimeApiClient.create_right_config(log=log,
|
||||||
config_path=api_client_config)
|
config_path=api_client_config)
|
||||||
|
|
||||||
|
ReplayGainUpdater.start_reply_gain(apiclient)
|
||||||
|
|
||||||
# TODO : Need to do setup_media_monitor call somewhere around here to get
|
# TODO : Need to do setup_media_monitor call somewhere around here to get
|
||||||
# import/organize dirs
|
# import/organize dirs
|
||||||
sdb = AirtimeDB(apiclient)
|
sdb = AirtimeDB(apiclient)
|
||||||
|
|
Loading…
Reference in New Issue