From 6e44c1bb8851c480247bc409890b765cf4164755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20H=C3=B6nig?= Date: Thu, 15 Jun 2017 11:11:28 +0200 Subject: [PATCH] bots: Check existance of config file in get_config_info(). --- bots/giphy/giphy.py | 7 ------- bots_api/bot_lib.py | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/bots/giphy/giphy.py b/bots/giphy/giphy.py index 5dd95cd..666d5e1 100644 --- a/bots/giphy/giphy.py +++ b/bots/giphy/giphy.py @@ -12,13 +12,6 @@ import re GIPHY_TRANSLATE_API = 'http://api.giphy.com/v1/gifs/translate' -if not os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'giphy.conf')): - print('Giphy bot config file not found, please set it up in this bot\'s folder ' - 'with the name \'giphy.conf\'\n\nUsing format:\n\n[giphy-config]\nkey=\n\n') - sys.exit(1) - - class GiphyHandler(object): ''' This plugin posts a GIF in response to the keywords provided by the user. diff --git a/bots_api/bot_lib.py b/bots_api/bot_lib.py index ecdccea..8fde0ac 100644 --- a/bots_api/bot_lib.py +++ b/bots_api/bot_lib.py @@ -102,7 +102,7 @@ class BotHandlerApi(object): our_dir, '..', 'bots', bot_name, bot_name + '.conf')) section = section or bot_name config = configparser.ConfigParser() - config.read(conf_file_path) + config.readfp(open(conf_file_path)) return dict(config.items(section))