From da3b2ae364c57f7891d9146149c6cab4a9abd7b0 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Tue, 24 Mar 2015 15:58:56 +0000 Subject: [PATCH] Only use Redis if a config is provided. --- dropbot/bot.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/dropbot/bot.py b/dropbot/bot.py index b80638f..6f4fb34 100644 --- a/dropbot/bot.py +++ b/dropbot/bot.py @@ -49,9 +49,13 @@ class DropBot(ClientXMPP): self.kills_muted = False self.office_api_key_keyid = kwargs.pop('office_api_keyid', None) self.office_api_key_vcode = kwargs.pop('office_api_vcode', None) - - self.redis_pool = ConnectionPool.from_url(kwargs.pop('redis_url', 'redis://localhost:6379/0')) - self.redis = Redis(connection_pool=self.redis_pool) + + if 'redis_url' in kwargs: + self.redis_pool = ConnectionPool.from_url(kwargs.pop('redis_url', 'redis://localhost:6379/0')) + self.redis = Redis(connection_pool=self.redis_pool) + else: + logging.warning('No DROPBOT_REDIS_URL defined, EVE API calls will not be cached!') + self.redis = None self.map = Map.from_json(pkgutil.get_data('dropbot', 'data/map.json')) jid = kwargs.pop('jid', None) @@ -245,7 +249,9 @@ class DropBot(ClientXMPP): return [self.stations[unicode(location_to_station(x.locationID))] for x in assets.assets if x.typeID == 27] def get_eveapi(self): - return EVEAPIConnection(cacheHandler=EVEAPIRedisCache(self.redis)) + if self.redis: + return EVEAPIConnection(cacheHandler=EVEAPIRedisCache(self.redis)) + return EVEAPIConnection() def get_eveapi_auth(self, keyid, vcode): return self.get_eveapi().auth(keyID=keyid, vCode=vcode) @@ -734,4 +740,4 @@ class DropBot(ClientXMPP): return 'This only works in MUC rooms' names = self.plugin['xep_0045'].getRoster(msg['from'].bare) - return 'RAGE PING: {} :frogsiren:'.format(', '.join(names)) \ No newline at end of file + return 'RAGE PING: {} :frogsiren:'.format(', '.join(names))